我有一个像这样的选择查询:
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
...
提前致谢。
答案 0 :(得分:1)
您不能简单地在静态SQL中使用列别名的动态值。
您将不得不使用固定值:AS column_name
一种可以实现的方法是动态创建查询,查看prepared statements。