I am wondering can you create an array variable in MySQL? I know that you can create a normal variable like so SET @var1 = "myvar"; but is there a way of creating an array? If so how?
-
1Did you try google? stackoverflow.com/questions/12176709/…Digital Chris– Digital Chris2013-12-30 18:52:13 +00:00Commented Dec 30, 2013 at 18:52
-
MySQL does not support arrays. Neither in the procedural language nor as a data type.user330315– user3303152013-12-31 11:37:15 +00:00Commented Dec 31, 2013 at 11:37
Add a comment
|
1 Answer
You can create an array like so
SET @arrayVar = 'var1,var2,bar3,foo4';
It can be used thus
select from myTable where find_in_set(myTable.myColumn, @arrayVar);
If you want to create an array from a query, you can use temporary tables
create temporary table if not exists tmp_table select myColumn from myTable where
1 Comment
yoni
works also on calculated value like :
find_in_set(month(mytable.myDate), @arrayVar)