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!

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.