Mybatis plus實現(xiàn)Distinct去重功能
不??攏?喜?/p>
QueryWrapper queryWrapper = new QueryWrapper(); queryWrapper.select('DISTINCT no,name').orderByAsc('no'); return mapper.selectList(queryWrapper);
PS:
順便一提,指明查詢出后的結(jié)果輸出類型,可以參考如下:
QueryWrapper<TablePo> queryWrapper = new QueryWrapper<>(); queryWrapper.select('DISTINCT no,name').orderByAsc('no'); return mapper.selectList(queryWrapper);distinct去重復(fù)查詢的使用
查詢的結(jié)果有時會有重復(fù)值,需要去除重復(fù)值,在sql查詢中使用distinct關(guān)鍵字很方便的達到效果。例如:
SELECT distinct ckbm,qy,hwbm FROM base_kf_hwxx WHERE ckbm = ’101’ AND qy = ’A’ AND isnull(hwxx_status,0)=0 AND qybs = 0
對應(yīng)的實現(xiàn)代碼:
emptyhw_wrapper.select('distinct ckbm,qy,hwbm') .eq('ckbm', ckbm) .eq('qy', qy) .apply('isnull(hwxx_status,0)=0') .eq('qybs', 0);
指定查詢的字段時加上distinct關(guān)鍵字: select(“distinct ckbm,qy,hwbm”) 。
到此這篇關(guān)于Mybatis plus實現(xiàn)Distinct去重功能的文章就介紹到這了,更多相關(guān)Mybatis plus Distinct去重內(nèi)容請搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持好吧啦網(wǎng)!
相關(guān)文章:
1. 用腳本和查詢主動監(jiān)視Oracle 9i性能2. 深入探討Oracle數(shù)據(jù)庫10g的Shrink機制3. 實例講解Oracle數(shù)據(jù)庫自動增加ID的sql4. Oracle數(shù)據(jù)庫在線表格重定義功能簡介5. Oracle中如何從BasicFile遷移到SecureFile6. mysql-joins具體用法說明7. Oracle9i在線表格重定義來組織表格8. SQL Server使用PIVOT與unPIVOT實現(xiàn)行列轉(zhuǎn)換9. Oracle建表與創(chuàng)建序列詳細實例10. SQL Server判斷數(shù)據(jù)庫、表、列、視圖、存儲過程、函數(shù)是否存在總結(jié)
