解決distinct中使用多個欄位的方法

2022-04-07 09:26:54 字數 323 閱讀 6059

眾所周知,distinct可以列出不重複的記錄,對於單個字段來說distinct使用比較簡單,但是對於多個字段來說,distinct使用起來會使人發狂。而且貌似也沒有見到微軟對distinct使用多字段的任何說明。下面就提供了一種方法可以在使用distinct的時候同時使用多個字段。

select 要使用欄位1,要使用欄位2 from 表名 where id in (select min(id) from 表名 group by 不重複欄位名)

例:select byid,id from bbs where id in (select min(id) from bbs group by byid)

完美解決distinct中使用多個欄位的方法

眾所周知,distinct可以列出不重複的記錄,對於單個字段來說distinct使用比較簡單,但是對於多個字段來說,distinct使用起來會使人發狂。而且貌似也沒有見到微軟對distinct使用多字段的任何說明。下面就提供了一種方法可以在使用distinct的時候同時使用多個字段。select 要...

在Django中使用DISTINCT

有時候想用distinct去掉queryset中的重複項,看django文章中是這麼說的 author.objects.distinct entry.objects.order by pub date distinct pub date entry.objects.order by blog dis...

MyEclipse中使用多個Tomcat

最近處於兩個專案的結合點,新的專案要做,剛做完的專案也還有很多需要修改的地方。所以經常需要來回切換,哥們兒們都知道來回倒騰幾個專案的痛苦。今天終於突發奇想,能不能同時弄幾個tomcat,這樣就不用總是修改配置檔案 重啟了。size large color red 第一步 color size 之前用...