delete from Student
where Name in( select Name from Student group by Name having count(Name) > 1) and
ID not in(select max(ID) from Student group by Name having count(Name) > 1 )
Student是要删除的目标表
Name是对应重复的字段
二 大小写敏感
select *
from Student
where Name collate Chinese_PRC_CS_AS != UPPER(Name )
把Name字符串全部改为大写。
collate解释上说其是选择排序用,但也可用在查询区分大小写上,如:
select * from tablename where column1 collate Chinese_PRC_CS_AS= 'Xxxx'
select * from s where sn collate Chinese_PRC_CS_AS like 'L%'
CI 指定不区分大小写,CS 指定区分大小写。
AI 指定不区分重音,AS 指定区分重音。
Omitted 指定不区分大小写,WS 指定区分大小写。