Mybatis plus實現(xiàn)Distinct去重功能
不啰嗦,上菜
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去重復查詢的使用
查詢的結(jié)果有時會有重復值,需要去除重復值,在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
對應的實現(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)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Spring?Boot自定義Starter組件開發(fā)實現(xiàn)配置過程
SpringBoot中的starter是一種非常重要的機制,能夠拋棄以前繁雜的配置,將其統(tǒng)一集成進?starter,應用者只需要在maven中引入starter依賴,這篇文章主要介紹了Spring?Boot自定義Starter組件開發(fā)實現(xiàn),需要的朋友可以參考下2022-06-06SpringBoot+MybatisPlus+Mysql+JSP實戰(zhàn)
這篇文章主要介紹了SpringBoot+MybatisPlus+Mysql+JSP實戰(zhàn),文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2020-12-12