MYSQL: how to search for fields that hold values sep. by commas?

Posted by andufo on Stack Overflow See other posts from Stack Overflow or by andufo
Published on 2010-05-15T01:03:41Z Indexed on 2010/05/15 1:14 UTC
Read the original article Hit count: 279

Filed under:

hi. i have 2 tables:

  1. tags (id_tag,name)
  2. news (id,title,data,tags)

The field news>tags is a varchar(255). Im planning to put data like this in that field: "1,7,34"

That means that a particular row in news is linked to tags 1, 7 and 34 from the tags table.

Then, how can i search for ALL news records that have the 34 value (among others) in the tags field?

Is there a better way to do this?

© Stack Overflow or respective owner

Related posts about mysql