Search code examples
sqldatabaserdbms

SQL - how to pull multiple rows in WHERE statement


Lets say I have a simple table. Each row is a product getting shipped...with a unique ID number. I want a result of the SELECT fields for a set of 5 ID numbers... Is there a simpler way to return the five rows of data other than what I've done before?

Ideally I want to copy/paste a list of IDs in the WHERE clause like: WHERE ID = 1, 19, 35, 70, 121

SELECT ID, Shipping Date, Estimated_Ready_date FROM reportB 
WHERE ID = 1 or ID = 19 or ID = 35 or ID = 70 or ID = 121

Solution

  • please use below query,

    SELECT ID, Shipping Date, Estimated_Ready_date FROM reportB 
    WHERE ID IN (1, 19, 35, 70, 121);