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

前端之家收集整理的这篇文章主要介绍了SQL语句中的“set 0”有什么作用?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我对这个sql语句的含义感到困惑:
  1. SELECT exhibitor_categories+0 from exhibitor_registry

什么是Exhibitor_categories 0?它返回返回的每一行的数字.

Exhibitor_categories定义为:

  1. set('contemporary','classical impression / transitional','outdoor','home accessories')

谢谢你的时间 :)

解决方法

它隐含地将设定值转换为INTEGER.

集合被视为位图,因此第一个值设置位0,第二个值设置位1等.

  1. MysqL> CREATE TABLE exhibitor_registry(exhibitor_categories set('contemporary','home accessories') NOT NULL);
  2.  
  3. Query OK,0 rows affected (0.08 sec)
  4.  
  5. MysqL> INSERT
  6. -> INTO exhibitor_registry
  7. -> VALUES ('contemporary,classical impression / transitional,outdoor');
  8. Query OK,1 row affected (0.03 sec)
  9.  
  10. MysqL> SELECT exhibitor_categories
  11. -> FROM exhibitor_registry;
  12. +----------------------------------------------------------+
  13. | exhibitor_categories |
  14. +----------------------------------------------------------+
  15. | contemporary,outdoor |
  16. +----------------------------------------------------------+
  17. 1 row in set (0.00 sec)
  18.  
  19. MysqL> SELECT exhibitor_categories + 0
  20. -> FROM exhibitor_registry;
  21. +--------------------------+
  22. | exhibitor_categories + 0 |
  23. +--------------------------+
  24. | 7 |
  25. +--------------------------+
  26. 1 row in set (0.00 sec)

猜你在找的MsSQL相关文章