我们如何获取 MySQL SET 列作为整数偏移量列表?

2023年 8月 27日 21.2k 0

我们如何获取 MySQL SET 列作为整数偏移量列表?

mysql> Create table set_testing( id INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, table SET('ABC','ABD','GHF') NOT NULL);
Query OK, 0 rows affected (0.08 sec)

mysql> Insert into set_testing (table) values('1');
Query OK, 1 row affected (0.06 sec)

mysql> Insert into set_testing (table) values('2');
Query OK, 1 row affected (0.06 sec)

mysql> Insert into set_testing (table) values('3');
Query OK, 1 row affected (0.02 sec)

mysql> Insert into set_testing (table) values('4');
Query OK, 1 row affected (0.02 sec)

mysql> Select * from set_testing;
+----+---------+
| id | table |
+----+---------+
| 1 | ABC |
| 2 | ABD |
| 3 | ABC,ABD |
| 4 | GHF |
+----+---------+
4 rows in set (0.00 sec)

现在,以下查询将获取 MySQL SET 列作为整数偏移量列表 -

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)

登录后复制

以上就是我们如何获取 MySQL SET 列作为整数偏移量列表?的详细内容,更多请关注每日运维网(www.mryunwei.com)其它相关文章!

相关文章

Oracle如何使用授予和撤销权限的语法和示例
Awesome Project: 探索 MatrixOrigin 云原生分布式数据库
下载丨66页PDF,云和恩墨技术通讯(2024年7月刊)
社区版oceanbase安装
Oracle 导出CSV工具-sqluldr2
ETL数据集成丨快速将MySQL数据迁移至Doris数据库

发布评论