Jump to content

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


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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.