gpt4 book ai didi

mysql - 从 select 内的子查询生成的别名字段

转载 作者:行者123 更新时间:2023-11-29 11:32:21 25 4
gpt4 key购买 nike

我有一个像这样的选择查询:

SELECT 
emp_des_company as 'Company',
(SELECT pav_des_valor FROM slt_pergunta_avaliacao pa, slt_avaliacao a WHERE pa.pav_idn_pergunta = 393 AND c.cas_idn_avaliacao = a.avl_idn_avaliacao)
FROM slt.case
...

我如何为这个子查询设置别名:

SELECT 
emp_des_company as 'Company',
(SELECT pav_des_valor FROM slt_pergunta_avaliacao pa, slt_avaliacao a WHERE pa.pav_idn_pergunta = 393 AND c.cas_idn_avaliacao = a.avl_idn_avaliacao) as (SELECT per_des_descricao WHERE per_idn_pergunta = 393)
FROM slt.case
...

提前致谢。

最佳答案

您不能简单地在静态 SQL 中使用动态值作为列别名。您必须使用固定值:AS column_name

一种替代方案是动态创建查询,请查看 prepared statements .

关于mysql - 从 select 内的子查询生成的别名字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37194651/

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