sqlredash

How do I write an efficient query to retrieve phone numbers attached to an ID?


I'm new to SQL and Redash, and I'm currently working on a query that retrieves phone numbers given the ID as shown below

SELECT "ID", "Phone_Number"
FROM Table
WHERE
"id" = '7559' OR
"id" = '1754' OR
"id" = '8679' OR
"id" = '6606' OR
....
....
"id" = '4166' OR
"id" = '7066' OR
"id" = '0027';

I have to manually type the "id" = '4166' OR clause every time I need to retrieve a phone number.

Whats an efficient way to do this?

Please Advise.


Solution

  • I finally used @Matteo Zanoni's method:

    SELECT "ID", "Phone_Number"
    FROM Table
    WHERE "id" IN (
    '7559',
    '1754',
    ...
    )