我们如何获取MySQL SET列作为整数偏移量列表?
我们可以借助MAKE_SET()函数获取MySQLSET列值作为整数偏移量列表。为了使其理解,我们正在创建一个名为“set_testing”的表,如下所示:
mysql> Create table set_testing( id INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, table SET('ABC','ABD','GHF') NOT NULL);
mysql> Insert into set_testing (table) values('1');
mysql> Insert into set_testing (table) values('2');
mysql> Insert into set_testing (table) values('3');
mysql> Insert into set_testing (table) values('4');
mysql> Select * from set_testing;
+----+---------+
| id | table |
+----+---------+
| 1 | ABC |
| 2 | ABD |
| 3 | ABC,ABD |
| 4 | GHF |
+----+---------+
4 rows in set (0.00 sec)现在,以下查询将获取MySQLSET列作为整数偏移量的列表-
mysql> Select MAKE_SET(types+0,'1','2','3') as output from doctypes1; +--------+ | output | +--------+ | 1 | | 2 | | 1,2 | | 3 | +--------+ 4 rows in set (0.00 sec)
热门推荐
1 如何训练狗狗不叫
2 训练狗狗不叫
3 训练狗狗随行
4 怎么训练狗狗不叫
7 训练比熊狗狗教程
10 上海狗狗训练
11 怎么训练狗狗上厕所
12 训练狗狗趴下
13 狗狗服从训练
14 训练狗狗拒食
15 训练狗狗笑
16 训练狗狗大便
17 训练狗狗立
18 训练狗狗捡东西