1
I have a table called users and want to catch some users as per id so I’m doing so:
select * from usuarios where id=2;
Only that I would like to get multiple users with different ids, for example get users who have id 2,8,10,11,20 at once. How could I do that in SQL? If I put the >
where id=2 and id=3
, wouldn’t work because he makes a comparison. Then someone would tell me how to do?
select * from usuarios where id=2 OR id=3 OR id=4...
– user28595
can use with
in
ex:select * from usuarios where id in (2, 8, 10)
or if you prefer, you can use the commandor
however, it must involve all conditions between parentheses. ex:select * from usuarios where (id=2 or id=3 or id=4)
. because in this way more conditions can still be placed "outside" of the parentheses. Ex:select * from usuarios where (id=2 or id=3) and usuarios.nome is not null
.– Ilario Junior