PostgreSQL Choose Where Multiple Statements OR

I have the following PgSQL query in which I am looking for where user_id is equal to any of the id set that I am looking for.

The question is, is there a way to simply formulate so that I do not have to put user_id =?

SELECT * 
FROM comments 
WHERE session_id=1 
AND (user_id=10 OR user_id=11 
     OR user_id=12 OR user_id=13 
     OR user_id=14 OR user_id=15 
     OR user_id=16)
+4
source share
1 answer
SELECT * 
FROM comments 
WHERE session_id=1 
  AND user_id in (10,11,12,13,14,15,16);

alternatively for this particular case:

SELECT * 
FROM comments 
WHERE session_id=1 
  AND user_id between 10 and 16;
+9
source

All Articles