Hossein Hossein - 8 months ago 39
SQL Question

Querying several keywords separately but in a batch with SQL

I have a list of 50 items and I want to extract some other data related to the from the my database (Postgres). One way is to write a simple

statement and manually each time I replace the item. But I believe this is very dumb to do. Is this possible that I make this work in an automatic way? Is there a For loop or something in SQL with which I can do this?


The IN construct facilitates selection on multiple values.

select * from MyTable where myfield in ( value1, value2, value3, value50 );