我有一個行業和名稱列的人員表。我可以通過使用以下查詢獲得基於行業的值在mysql表中有不同值的重複記錄
SELECT *
FROM `people`
ORDER BY `industry` ASC, `name` ASC
在我的表中有相同行業的記錄(人員)。是否有可能讓他們獲得相同的產出? 對於現在的查詢返回此
industry1
------
name1
industry1
------
name2
industry2
------
name
----------------------------------------------------
我怎麼能有它這樣?
industry1
------
name1
name2
industry2
------
name
var num = 0;
for(var i = 0;i < r.length; i++) {
var country = r[i].country;
if(i < r.length-1) nextCountry = r[i+1].country;
if(lastCountry != country && nextCountry == country) {
num = 0;
}
%>
<div class="<%= lastCountry %> <%= country %> <%= nextCountry %>"></div>
<div class="contact-list">
<div class="contact-info contact-padding">
<% if(r[i].industry) { %> <h2 class="h-style"><%= r[i].industry %></h2> <% }%>
<span class="name"><%= r[i].name %> <% if(r[i].segment) { %>(<%= r[i].segment %>)<% }%></span>
<span class="phone"><%= r[i].phone %></span>
<span class="email"><%@ "generic_email" %></span>
</div>
</div>
<%
\t num++;
var lastCountry = country;
}
%>
這是認爲我建立和消耗的數據,簡單地重複爲每個記錄的代碼相同的塊。如果我嘗試使用GROUP BY,它只返回
ONE OF THE INDUSTRIES
name1, name2,name3,name4, ...
phone number
email
意味着什麼? –
@FahadAnjum是的,具有相同行業標籤的人應該組合在一列 – k185
認真考慮處理應用程序代碼 – Strawberry