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
[email protected]
[email protected]
[email protected]
[email protected]
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 [email protected]
and [email protected]
just because they are different cases?
In computers, case sensitivity defines whether uppercase and lowercase letters are treated as distinct (case-sensitive) or equivalent (case-insensitive). For instance, when users interested in learning about dogs search an e-book, "dog" and "Dog" are of the same significance to them.
The default collations used by SQL Server and MySQL do not distinguish between upper and lower case letters—they are case-insensitive by default. The logic of this query is perfectly reasonable but the execution plan is not: DB2.
SQL keywords are by default set to case insensitive that means that the keywords are allowed to be used in lower or upper case. The names of the tables and columns specification are set to case insensitive on the SQL database server, however, it can be enabled and disabled by configuring the settings in SQL.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With