gpt4 book ai didi

mysql - 从 select 语句创建列名别名

转载 作者:太空宇宙 更新时间:2023-11-03 12:22:06 25 4
gpt4 key购买 nike

我正在尝试通过在另一个表中查找值来创建列别名。这是我正在尝试的 MySQL,但不断出现语法错误 - 任何帮助将不胜感激。

SELECT
product_code,
bField1 as (select [label_value] from [labels] where [field_value]='bField1'),
bField2 as (select [label_value] from [labels] where [field_value]='bField2'),
....
FROM products

最佳答案

尝试如下:

SELECT
product_code,
(select [label_value] from [labels] where [field_value]='bField1') as bField1,
(select [label_value] from [labels] where [field_value]='bField2') as bField2,
....
FROM products

关于mysql - 从 select 语句创建列名别名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19447915/

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