Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Is there a shorter way to write many WHERE clauses for single column in SQL?

I have this query:

SELECT * 
FROM users 
WHERE UPPER(column) = 'STRING1'  
   OR UPPER(COLUMN) = 'STRING2' 
   OR UPPER(COLUMN) = 'STRING3' 
   OR ... 
   OR UPPER(COLUMN) = 'ANYSTRING';

Here you can see that UPPER(column) is compared with multiple strings (strings are arbitrary). The query becomes massive as the number of strings to compare increases.

I’m wondering if there is some shorter way to write this query, maybe something like this?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

SELECT * 
FROM users 
WHERE UPPER(column) = ('STRING1' OR 'STRING2' OR ... OR 'ANYSTRING')

Thanks!

>Solution :

select *
from users
where upper(column) in ('STRING1', 'STRING2', ... 'ANYSTRING')
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading