I'm new to SQL. I've got my table with 3 columns. Given a list of values (lets say ints for example 1, 4, 3) I want to select rows in which the second columns value equals something that the given list contains.
Is it possible to pass a list as an argument in SQL?
select * from TABLE1 where ...
How do i finish this statement for it to work as i explained?
I'm using PostgreSQL 9.4
Try the following query:
SELECT *
FROM TABLE1
WHERE col2 IN (1, 4, 3);
Most flavors of SQL support the IN
clause, which allows comparing a column against a sequence of values. In the query above, we compare col2
against a collection of numbers, but we can equally compare against string literals, etc.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments