Search in Tags Set in MySQL


/ Published in: PL/SQL
Save to your folder(s)

Lets say you have a table with field called "tags" that consists from tags separated by commas and you want to check whether it includes a required tag. Here the simplest ways of doing that.


Copy this code and paste it in your HTML
  1. -- 1st way
  2. WHERE FIND_IN_SET(" '.$tag.'", CONCAT(" ", TABLE.tags))
  3. LIMIT 1;
  4.  
  5. -- 2st way
  6. WHERE '.$tag.' IN(TABLE.tags)
  7. LIMIT 1;

URL: http://www.apphp.com/index.php?snippet=mysql-search-in-tags-set

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.