Return to Snippet

Revision: 64500
at August 14, 2013 19:38 by apphp-snippets


Initial Code
-- 1st way
SELECT *
FROM TABLE
WHERE FIND_IN_SET(" '.$tag.'", CONCAT(" ", TABLE.tags))
LIMIT 1;
 
-- 2st way 
SELECT *
FROM TABLE
WHERE '.$tag.' IN(TABLE.tags)
LIMIT 1;

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

Initial Description
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.

Initial Title
Search in Tags Set in MySQL

Initial Tags
sql

Initial Language
PL/SQL