数据库
首页 > 数据库> > SQL删除重复项 及 字段大小写敏感

SQL删除重复项 及 字段大小写敏感

作者:互联网

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     指定区分大小写。
 

标签:Name,删除,区分,大小写,collate,Student,SQL,select
来源: https://blog.csdn.net/fish_cake/article/details/122457269