Mega Code Archive

 
Categories / MySQL / Function
 

Locate records in which an attribute has been set (regardless of its combination with other attributes)

mysql> mysql> CREATE TABLE testset     -> (fontattr SET ('bold', 'italic', 'underlined')); Query OK, 0 rows affected (0.00 sec) mysql> mysql> INSERT testset VALUES ('bold,italic'); Query OK, 1 row affected (0.00 sec) mysql> mysql> mysql> SELECT * FROM testset WHERE FIND_IN_SET('italic', fontattr)>0; +-------------+ | fontattr    | +-------------+ | bold,italic | +-------------+ 1 row in set (0.00 sec) mysql> mysql> drop table testset; Query OK, 0 rows affected (0.00 sec) mysql> mysql>