AceAlfred
AceAlfred

Reputation: 1191

SQL: Select distinct - without highcase/lowcase duplicate

My query:

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

My result problem:

1, 1, Hello
1, 1, hello

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

Upvotes: 1

Views: 5526

Answers (3)

Fred
Fred

Reputation: 5808

Try running this query.

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.

Upvotes: 2

AceAlfred
AceAlfred

Reputation: 1191

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

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

Upvotes: 0

Kapil gopinath
Kapil gopinath

Reputation: 1053

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

Upvotes: 0

Related Questions