Forum Moderators: open
RECORD_NO ¦ FIELD VALUE
1 ¦ g1,g2,g3,g4,g5
2 ¦ g3,g4,g5,g6
3 ¦ g2,g6
What I'm wanting as an output would be
g1=1, g2=2, g3=2, g4=2, g5=2, g6=2
The main aim of the way the table is set up is to make maintenance easier, rather than having to update the table and code everytime I want to add a new value. I'm using PHP and MySQL if its any help.
RECORD_NO ¦ FIELD VALUE
1 ¦ g1
1 ¦ g2
1 ¦ g3
1 ¦ g4
1 ¦ g5
2 ¦ g3
2 ¦ g4
2 ¦ g5
2 ¦ g6
3 ¦ g2
3 ¦ g6
Or if you need to, make a seperate table like that.
Then try the following query:
SELECT FIELD_VALUE,COUNT(*) FROM table GROUP BY FIELD_VALUE HAVING COUNT(*) > 1