MySQL create view from concat value

Posted by cnotethegr8 on Stack Overflow See other posts from Stack Overflow or by cnotethegr8
Published on 2012-03-20T11:10:05Z Indexed on 2012/03/20 11:29 UTC
Read the original article Hit count: 246

Filed under:

Lets say I have a table as follows,

+----+-------------+
| id | value       |
+----+-------------+
| 1  | aa,bb,cc,dd |
| 2  | ee,ff,gg,hh |
+----+-------------+

I want to be able to search this table to see if id = 1 AND value = 'cc'. Im assuming a good way of doing this is to grab the id = 1 row and split its values into separate rows in a new view. Something like,

+-----+
| val |
+-----+
| aa  |
| bb  |
| cc  |
| dd  |
+-----+

I would like to do all of this in MySQL. How can i do this, and is there possibly a better way to do it?

© Stack Overflow or respective owner

Related posts about mysql