I've stored lists of numbers in columns, that looks like this:
1,2,6,7
I've chosen varchar(255) to store these values. Let's call this column "numbers".
Now, I want to find out which rows holds a certain number. So, these two query should both return 1, right?
Query 1: SELECT 6 IN(1,2,6,7);
Query 2: SELECT 6 IN(numbers) FROM my_table;
The problem is that MySQL seems to interpret the second query like this:
SELECT 6 IN('1,2,6,7') FROM my_table;
...since "1,2,6,7" is stored as a string, so it doesn't work.
How can I make MySQL understand that I want it to be interpreted like QUERY 1?
1,2,6,7
I've chosen varchar(255) to store these values. Let's call this column "numbers".
Now, I want to find out which rows holds a certain number. So, these two query should both return 1, right?
Query 1: SELECT 6 IN(1,2,6,7);
Query 2: SELECT 6 IN(numbers) FROM my_table;
The problem is that MySQL seems to interpret the second query like this:
SELECT 6 IN('1,2,6,7') FROM my_table;
...since "1,2,6,7" is stored as a string, so it doesn't work.
How can I make MySQL understand that I want it to be interpreted like QUERY 1?