MySQL case-insensitive DISTINCT

case-insensitive, database, distinct, mysql, sql

Solution

Try to use `upper` function

SELECT DISTINCT UPPER(email) FROM `jm_order`

you can also use `lower` instead

SELECT DISTINCT LOWER(email) FROM `jm_order`

More information.

Problem

Can anyone tell me how i can SELECT DISTINCT from my database without it being case-sensitive? My query is ``` SELECT DISTINCT email FROM `jm_order` ``` The results brings out all the emails in the table but repeats the ones with different cases. This is expected because the values are different case wise. e.g ``` sam@gmail.com josh@gmail.com Sam@gmail.com john@gmail.com ``` But what i want is for the same emails, to be grouped together regardless of the case. What adjustment can i make to my SQL to stop it from repeating for example `sam@gmail.com` and `Sam@gmail.com` just because they are different cases?

Original source

Related problems