select * from tb t where not exists (select * from tb where t.id=id and t.no>no)
select * from tb where not exists (select * from tb t where t.id=id and t.no<no)
select * from tb where not exists (select * from tb t where t.id=id and t.no<no)
select * from tb where not exists (select * from tb t where t.id=id and t.no<no)别名的位置不同,一个是内表,一个是外表,返回的值也不同
---------
相同id取最小的noselect * from tb where not exists (select * from tb t where t.id=id and t.no<no)
---------
相同id取最大的no
第二条求id相同,no的最大值
select * from tb where not exists (select * from tb t where t.id=id and t.no<=no)
要<=就一样的了
第二条也是求id相同,no的最小值
---子查询中的id与外面tb的ID比较 子查询中的no比外面的小 所以是取重复值中的no最小的那个
select * from tb where not exists (select * from tb t where t.id=id and t.no<no)