Jump to content

SELECTing from a column WHERE a number appears in a particular field's output


PTS

Recommended Posts

I run a sports team website that's heavily data drive.

 

Two of my many tables are a "roster" table and a "news" table. One of the fields in the "news" table is playerRefID. If a particular "news" story is heavily about a player, I mark that field with the player's ID number from the "roster" table. I have no problem displaying news on just one particular player but I do have a problem if a story is about more than one players. The playersRefID field is a varchar field with numbers separate by commas if the "news" is about more than one player.

 

For example, if a news story is about Player #11, Player #21 and Player #23, then in the news table, that playersRefID field would be '11,21,23'

 

What statement would I use to SELECT if a particular player's ID is in that comma-separated "array"? If there even an option for this? If there a better option I should use?

 

Thanks in advance!

Link to comment
Share on other sites

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.