Open markomilivojevic opened 2 months ago
This can be used as a workaround:
mysql> drop table if exists test; create table test(languages multi); insert into test values(1, (1)), (2,(2)), (3,(1,2)), (4,(2,1)), (5,(1,2,3)); select * from test where any(languages) in (1) and any(languages) in (2);
--------------
drop table if exists test
--------------
Query OK, 0 rows affected (0.00 sec)
--------------
create table test(languages multi)
--------------
Query OK, 0 rows affected (0.01 sec)
--------------
insert into test values(1, (1)), (2,(2)), (3,(1,2)), (4,(2,1)), (5,(1,2,3))
--------------
Query OK, 5 rows affected (0.00 sec)
--------------
select * from test where any(languages) in (1) and any(languages) in (2)
--------------
+------+-----------+
| id | languages |
+------+-----------+
| 3 | 1,2 |
| 4 | 1,2 |
| 5 | 1,2,3 |
+------+-----------+
3 rows in set (0.00 sec)
--- 3 out of 3 results in 0ms ---
Ok, thanks, that works. Can be closed.
Proposal:
Given that the
languages
column is MVA, the following:works:
doesn't work:
I want to be able to return all results from the
test
index where each row contains both languages (1, 2) among the others.Should have JSON/PHP support as well.
Checklist:
To be completed by the assignee. Check off tasks that have been completed or are not applicable.