Is it possible in MySQL to select from a static set of integers? Given an array of integers like 1 and 2, what is the correct syntax in MySQL to do something like:
select
*
from
(values(1),(2))
Which should return one row containing the number 1 and one row containing the number 2.
In other SQL than MySQL (e.g. MSSQL) this is possible. Is there a way to do this in MySQL?
mysql> select *from PassingAnArrayDemo; The following is the output. The following is the syntax to send an array parameter with the help of where IN clause. mysql> SELECT * -> FROM PassingAnArrayDemo where id IN(1,3,6);
The SELECT statement is used to select data from a database. The data returned is stored in a result table, called the result-set.
An array is type of data structure defined in MySQL. MySQL provides WHERE IN clause that is useful to apply in the array variable to produce the query set from specific table in the database. WHERE IN clause supports to fetch data values from an array of parameters provided in the query statement in MySQL.
In MySQL subquery can be nested inside a SELECT, INSERT, UPDATE, DELETE, SET, or DO statement or inside another subquery. A subquery is usually added within the WHERE Clause of another SQL SELECT statement. You can use the comparison operators, such as >, <, or =.
I think you mean something like this?
SELECT 1 UNION SELECT 2 UNION SELECT 3
sorry for my english
you can use (IN) like this
SELECT * FROM Table WHERE id IN (1,2,3....)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With