这要用另一个或多个行来比较才行,也就是说,重复的行,你选哪一个. 如果两行是完全重复的,则: select distinct * from [CustomerRegisters] WHERE studentd<'500' 如果只是部分重复,而有不重复的,比如 id 是唯一的,则: select * from [CustomerRegisters] a WHERE studentd<'500' and not exists( select 1 from CustomerRegisters where studentd=a.studentd and id>a.id
没太懂,你可以这样写下 不知道是不是要的结果 select * from [CustomerRegisters] WHERE studentd<'500' group by studentd
差个右括号: select * from [CustomerRegisters] a WHERE studentd<'500' and not exists( select 1 from CustomerRegisters where studentd=a.studentd and id>a.id)
select distinct * from [CustomerRegisters] WHERE studentd<'500'
是想去重复的吗 distinct 关键字就好了 select * from [CustomerRegisters] WHERE studentd<'500'把表结构和结果贴出来
如果两行是完全重复的,则:
select distinct * from [CustomerRegisters] WHERE studentd<'500'
如果只是部分重复,而有不重复的,比如 id 是唯一的,则:
select * from [CustomerRegisters] a WHERE studentd<'500' and not exists(
select 1 from CustomerRegisters where studentd=a.studentd and id>a.id
select * from [CustomerRegisters] WHERE studentd<'500'
group by studentd
select * from [CustomerRegisters] a WHERE studentd<'500' and not exists(
select 1 from CustomerRegisters where studentd=a.studentd and id>a.id)
select distinct * from [CustomerRegisters] WHERE studentd<'500'
distinct 关键字就好了
select * from [CustomerRegisters] WHERE studentd<'500'把表结构和结果贴出来
谢谢您的答案!不过这样只能查出不重复的列ID的行!在STUdentd列中有着大量一样值得行,有些可能有几千行,我需要每一个STUDENTD 一个ID值只输出一行
这个有办法吗?