Jump to content

How do you get info from a MySql comma separated value column using sql?


floridaflatlander

Recommended Posts

I have a  test sql query like the one below that works fine

 

SELECT columns FROM table2, smf_members WHERE table2.id_member = smf_members.id_member AND smf_members.id_group = '9' ORDER BY  member_name;

 

However smf has group membership in a column called id_group and  a column called additional_groups which holds CSVs.

 

Can I write a SELECT query and change  smf_members.id_group = '9' to query both the id_group column and the additional CSVs column for a group #.

 

I need this to print out a table using while loop.

Would this help?

 

SELECT columns
FROM table2
JOIN smf_members ON table2.id_member = smf_members.id_member
WHERE smf_members.id_group = '9' OR find_in_set('9', smf_members.additional_groups)
ORDER BY member_name

 

FIND_IN_SET()

It worked like a charm.

 

I tried to just add  AND smf_members.id_group = '9' OR find_in_set('9', smf_members.additional_groups) and I couldn't get it to work. I just added AND find_in_set('9', smf_members.additional_groups) and it only pulled from the one (csv)column.

 

I put your sql code in and it worked,

 

Thanks

S

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.