Bookmark and Share
how to use MySQL SET Datatype
(Publish Date: 2009-10-7 5:22pm, Total Visits: 4265, Today: 1, This Week: 1, This Month: 6)

A table article has a column is defined as SET datatype;

mysql> desc article localized;
| localized | set('articleName','articleSubname','topTitle','description','content','keywords',
'status','isDeleted','featured','youmakerEmbed','DJYRecommend','globalImportantNews',
'homepageTop','commentaryTop','noCopyright','lifeTopOne','yuleTopOne','frontPageBigTop',
'allowComment','commentDefaultPublish','issueDate','imageName','imageNameSmall',
'imageRight','imgFrontPageBigTop','articleCombo') | YES  |     | NULL    |

mysql> select localized, LPAD(BIN(localized+0),26,'0') from article limit 3;
+---------------------------------------------+-------------------------- -----+
| localized                                   | LPAD(BIN(localized+0),26, '0') |
+---------------------------------------------+-------------------------- -----+
| articleName                                 | 00000000000000000000000001  |
| globalImportantNews,homepageTop,noCopyright | 00000000000101100000000000  |
| articleName,topTitle                        | 00000000000000000000000101  |
+---------------------------------------------+-------------------------- -----+

mysql> select substring('00000000000000000000000001', 26);
+---------------------------------------------+
| substring('00000000000000000000000001', 26) |
+---------------------------------------------+
| 1                                           |
+---------------------------------------------+

Here is a good link for the MySQL SET data type:

http://dev.mysql.com/tech-resources/articles/mysql-set-datatype.html

and here are some useful string functions for SET type.

FIELD(), FIND_IN_SET();