-1

Possible Duplicate:
Can Mysql Split a column?
Mysql string split

I have this in a table:

id  color
1   red/green/blue/orange
2   blue
3   
4   red/green

I will a sql query maybe this :

color
red
green
blue
orange
blue
red
green
Community
  • 1
  • 1
Ilhan Er
  • 7
  • 2
  • normalize your table, and this problem will go away automatically. – Marc B Oct 31 '12 at 15:03
  • 6
    No, *please* don't do that. Every time you design a table like this a kitten somewhere dies. I recommend you read here: http://en.wikipedia.org/wiki/Database_normalization – Mark Byers Oct 31 '12 at 15:03

1 Answers1

0

What the commenters want to suggest, is splitting the values into separate rows:

id color
1  red
1  green
1  blue
1  orange
2  blue
3  NULL
4  red
4  green

Then you can easily select:

select color from color_table;

or every color only once:

select distinct color from color_table;
Olaf Dietsche
  • 72,253
  • 8
  • 102
  • 198