Reputation: 327
I am coming from a PostgreSQL background and there I could write the following:
SELECT * FROM my_table WHERE my_table.text_column = ANY(:input::text[])
In this query, I am passing an array of string values. This allowed me to pass any number of input parameters, without knowing the size in advance.
How would you do this in MySQL? I am targeting MySQL 8, if that matters.
Upvotes: 2
Views: 53
Reputation: 378
One way is to use the IN keyword.
SELECT * FROM my_table WHERE my_table.text_column IN('item1','item2','item3');
http://www.mysqltutorial.org/sql-in.aspx
Edit: Without changing the query: If you create a temporary table for the list of items, you can use:
SELECT * FROM my_table WHERE my_table.text_column IN
(SELECT item from temptable);
Upvotes: 1