gpt4 book ai didi

jquery - MySQL 从特定值中选择

转载 作者:行者123 更新时间:2023-11-29 10:01:28 26 4
gpt4 key购买 nike

我正在尝试执行一个查询,将文字值列表转换为结果集,但如果不进行联合,我无法完全弄清楚语法。

以下是我尝试过的一些方法:

SELECT *
FROM (1, 2, 3, 5, 6) temp(id);

select x.* from
(('test-a1', 'test-a2'), ('test-b1', 'test-b2'), ('test-c1', 'test-c2')) x(col1, col2);

类似于我期望的结果集如下所示:

id
1
2
3
4
5
etc…

col1 | col2
test-a1, test-a2
test-b1, test-b2
test-c1, test-c2
etc…

最佳答案

CREATE TEMPORARY TABLE temp_id_table
( id INT UNSIGNED NOT NULL );

INSERT INTO temp_id_table ( id ) VALUES
(1),(2),(3),(4),(5)
;

select id from temp_id_table;

结果:

id
1
2
3
4
5

关于jquery - MySQL 从特定值中选择,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52859636/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com