Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL - Where clause: comparing a column with multiple values

Tags:

sql

Is there any generic command or syntax in SQL to allow one to have multiple values in a where statement without using OR? OR just gets tedious when you have many values to choose from and you only want say half of them. I want to return only columns that contain certain values. I am using Cache SQL, but as I said, a generic syntax might be helpful as well because most people are unfamiliar with Cache SQL. Thanks!

like image 907
eatonphil Avatar asked Dec 10 '25 15:12

eatonphil


1 Answers

You should use IN:

... where column_name in ('val1', 'val2', ...);
like image 194
Andrew Logvinov Avatar answered Dec 12 '25 04:12

Andrew Logvinov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!