I am running a query where you search an array value. I found a solution as to how to do this on Stackoverflow, however, it does not seem to give the output I would expect. Here are the examples, can you tell me where I am going wrong please:
I have a table with a column called departments and some of the examples rows contain values like:
1: 2,4
2: 1,7,2,8,9,4
3: 4, 2
I run a query on this:
SELECT * FROM udf_multi_value WHERE udfdefid = '1' AND department IN ( 1, 7, 2, 8, 9, 4 );
This returns all rows in the results, which is what I would expect. However, when I run:
SELECT * FROM udf_multi_value WHERE udfdefid = '1' AND department IN ( 2, 4 )
it only returns row 1 and 3. As 2 and 4 are in all rows I wuld ave thought it should return row 2 as well.
Any help greatly appreciated.
FIND_IN_SETudf_multi_value(idint(11) NOT NULL AUTO_INCREMENT,registrantidvarchar(350) NOT NULL,departmentvarchar(350) DEFAULT NULL,udfdefidvarchar(255) NOT NULL,valuetext NOT NULL,isdefaulttinyint(4) DEFAULT '0', PRIMARY KEY (id) ) ENGINE=MyISAM AUTO_INCREMENT=14 DEFAULT CHARSET=latin1