sql 过滤重复数据
发布日期:2021-06-29 17:05:06 浏览次数:2 分类:技术文章

本文共 360 字,大约阅读时间需要 1 分钟。

id   name

1    苹果

2    梨
3    香蕉
4    香蕉
5    梨

正常查询

select  * from Table_1

结果

id   name

1    苹果

2    梨
3    香蕉
4    香蕉
5    梨

 

过滤重复1

select * from Table_1 a where not exists (select * from Table_1 where  a.name=name and a.id

id   name

1    苹果

4    香蕉
5    梨

重点a.id<id

过滤重复2

select * from Table_1 a where not exists (select * from Table_1 where  a.name=name and a.id>id)

id  name

1    苹果

2    梨
3    香蕉

重点a.id>id

 

 

 

 

转载地址:https://cplvfx.blog.csdn.net/article/details/103366753 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:MetInfo-CMS,米拓CMS 后台页面修改日记(第一次整理)
下一篇:ThinkPHP 本地正常 线上提示重定向的次数过多

发表评论

最新留言

关注你微信了!
[***.104.42.241]2024年04月17日 02时54分39秒