SQL语句中的“set 0”有什么作用?

前端之家收集整理的这篇文章主要介绍了SQL语句中的“set 0”有什么作用?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我对这个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)
原文链接:https://www.f2er.com/mssql/77061.html

猜你在找的MsSQL相关文章