where condition increasing

1

I have a table called users and I want to get some users according to the id so I am doing this:

select * from usuarios where id=2;

I just want to get several users with different ids, for example get users who have the id 2,8,10,11,20 at one time. How could I do this in SQL? If I put > where id=2 and id=3 , it would not work because it compares. So could anyone tell me how to do it?

    
asked by anonymous 27.02.2016 / 18:33

1 answer

5

Use the command in , it will check for occurrences in the fields, and return the record where there were occurrences, the purpose of it is to replace several clauses, where the or command is used.

Example:

select * from usuarios where id in(2,8,10,11,20);

See more about it: link

    
27.02.2016 / 18:46