Finding comma separated values with a colon delimiter
- by iconMatrix
I am setting values in my database for tourneyID,Selected,Paid,Entered,date then separating each selection with a colon
So I have a string that may look like this
187,S,,,09-21-2013:141,S,,,06-21-2013:144,S,,,05-24-2013
but it also could look like this
145,S,,,07-12-2013:142,S,,,05-24-2013:187,S,,,09-21-2013
and some times is looks like this
87,S,,,07-11-2013:125,S,,,06-14-2013
I am trying to find this sequence: 187,S,,,09-21-2013
I have data stored like that because I paid a programmer to code it for me. Now, as I learn, I see it was not the best solution, but it is what I have till I learn more and it is working.
My problem is when using LIKE it returns both the 187 and 87 values
$getTeams = mysql_query("SELECT * FROM teams
WHERE (team_tourney_vector LIKE '%$tid,S,P,,$tourney_start_date%'
OR team_tourney_vector LIKE '%$tid,S,,,$tourney_start_date%')
AND division='$division'");
I tried this using FIND_IN_SET()
but it would only return the the team id for this string
187,S,,,09-21-2013:141,S,,,06-21-2013:144,S,,,05-24-2013
and does not find the team id for this string
145,S,,,07-12-2013:142,S,,,05-24-2013:187,S,,,09-21-2013
SELECT * FROM teams WHERE FIND_IN_SET('187',team_tourney_vector) AND (team_tourney_vector LIKE '%S,,,09-21-2013%')
Any thoughts on how to achieve this?