selecttid,subject,count(tid)asnumfromcdb_postsgroupbytidorderbynumdesclimit5;-----------------你根據tid分組後,對於列subject的值,只會取第一行的值.或你可以用max(subject)來替換subject看看。
- 情感問答
- 答案列表
mysql 去重查詢:mysql資料庫去重查詢[朗讀]
selectdistinctdate,cost,pricefromtimeorderbydateasc。
sql語句:select`lcontent`from`caiji_ym_liuyan`這樣查詢的時候就會有很多重複的記錄例子:就會出現這樣的重複修改後的sql語句:selectdistinct(`lcontent`)from`caiji_ym_liuyan`查詢結果:在sal查詢中這種方法是在文章的時候需要用到,這樣就會防止重複的出現。
在語句中加個關鍵字就行了;selectdistinctdomainfrom表名;查詢的結果中就已經自動去重了。
select*from表名where欄位in(selectmax(欄位)from表名groupbyuid);