Is there a way to select data where any one of multiple conditions occur on the same field?
Example: I would typically write a statement such as:
select
while in
is a shortcut for or
and I wasn't sure how I could combine in
with and
, I did it this way
SELECT * FROM table
WHERE column1='x' AND (column2='y' OR column2='z');
select * from TABLE where field IN (1,2,3)
You can also conveniently combine this with a subquery that only returns one field:
select * from TABLE where field IN (SELECT boom FROM anotherTable)
OR:
SELECT foo FROM bar WHERE baz BETWEEN 1 AND 3
WHERE field IN (1, 2, 3)
You can still use in for
select *
from table
where field = '1' or field = '2' or field = '3'
its just
select * from table where field in ('1','2','3')
select * from TABLE where field in (1, 2, 3)