SQL:选择distinct - 没有highcase / lowcase重复

时间:2021-05-17 02:01:13

My query:

SELECT distinct [ID], [IDGROUP], [DESCRIPTION]
FROM table

My result problem:

我的结果问题:

1, 1, Hello
1, 1, hello

1,1,你好1,1,你好

How can I set a filter where I do not select duplicates where the difference is only the high/low case letter??

如何设置一个过滤器,我不选择重复,其中差异只是高/低案例字母?

3 个解决方案

#1


2  

Try running this query.

尝试运行此查询。

SELECT distinct [ID], [IDGROUP], [DESCRIPTION] COLLATE SQL_Latin1_General_CP1_CI_AS FROM table

SELECT distinct [ID],[IDGROUP],[DESCRIPTION] COLLATE SQL_Latin1_General_CP1_CI_AS FROM table

Here you are basically saying ignore case on the DESCRIPTION column

在这里,您基本上是在说明列中说明忽略大小写

CI = Case insensitive AS = Accent sensitive.

CI =不区分大小写AS =重音敏感。

#2


1  

I guess mysql engine does not duplicate based on letter case by default. That is both Hello and hello is considered same.

我猜默认情况下mysql引擎不会基于字母大小写重复。这就是Hello和hello被认为是相同的。

#3


0  

Not sure if this is the best way but this worked for me:

不确定这是否是最好的方式,但这对我有用:

SELECT distinct [ID], [IDGROUP], Upper([DESCRIPTION]) as [DESCRIPTION]
FROM table

#1


2  

Try running this query.

尝试运行此查询。

SELECT distinct [ID], [IDGROUP], [DESCRIPTION] COLLATE SQL_Latin1_General_CP1_CI_AS FROM table

SELECT distinct [ID],[IDGROUP],[DESCRIPTION] COLLATE SQL_Latin1_General_CP1_CI_AS FROM table

Here you are basically saying ignore case on the DESCRIPTION column

在这里,您基本上是在说明列中说明忽略大小写

CI = Case insensitive AS = Accent sensitive.

CI =不区分大小写AS =重音敏感。

#2


1  

I guess mysql engine does not duplicate based on letter case by default. That is both Hello and hello is considered same.

我猜默认情况下mysql引擎不会基于字母大小写重复。这就是Hello和hello被认为是相同的。

#3


0  

Not sure if this is the best way but this worked for me:

不确定这是否是最好的方式,但这对我有用:

SELECT distinct [ID], [IDGROUP], Upper([DESCRIPTION]) as [DESCRIPTION]
FROM table