Possible Duplicate:
Is storing a comma separated list in a database column really that bad?
I have a mysql db column of comma separated text:
id keys
------------
1 Key1, Key2
2 key3
3 key2, key3, key4
4 key5, key2
Question 1
I need results like this:
id keys
----------
1 Key1
2 Key2
3 key3
4 key4
5 key5
Question 2
Also I need a second query to match the above condition. eg.
select all the rows with key2
Output should be
id
---
1
4
NOTE: Only in a single query, no stored procedures, no functions.
I have seen similar questions but with not the desired answer.
NOTE : Thanks for suggesting that data should not be stored in a comma seprated field. But I have not developed the system and database. I am just about to do a samll upgradation.