我对这个sql语句的含义感到困惑:
SELECT exhibitor_categories+0 from exhibitor_registry
什么是Exhibitor_categories 0?它返回返回的每一行的数字.
Exhibitor_categories定义为:
set('contemporary','classical impression / transitional','outdoor','home accessories')
谢谢你的时间 :)
解决方法
它隐含地将设定值转换为INTEGER.
集合被视为位图,因此第一个值设置位0,第二个值设置位1等.
MysqL> CREATE TABLE exhibitor_registry(exhibitor_categories set('contemporary','home accessories') NOT NULL); Query OK,0 rows affected (0.08 sec) MysqL> INSERT -> INTO exhibitor_registry -> VALUES ('contemporary,classical impression / transitional,outdoor'); Query OK,1 row affected (0.03 sec) MysqL> SELECT exhibitor_categories -> FROM exhibitor_registry; +----------------------------------------------------------+ | exhibitor_categories | +----------------------------------------------------------+ | contemporary,outdoor | +----------------------------------------------------------+ 1 row in set (0.00 sec) MysqL> SELECT exhibitor_categories + 0 -> FROM exhibitor_registry; +--------------------------+ | exhibitor_categories + 0 | +--------------------------+ | 7 | +--------------------------+ 1 row in set (0.00 sec)