gpt4 book ai didi

mysql - mysql中结果集的情况

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

我想在 mysql 中测试以下查询

SELECT result.* FROM 
(CASE WHEN (2 = 2)
THEN
(SELECT * FROM mytable WHERE myID =2814 )
END) result ;

但发送语法错误。知道有什么问题吗?

最佳答案

你可以像这样迂回地做到这一点

SET @query := NULL;

SELECT @query := t.qry
FROM
( SELECT
CASE WHEN 2 = 2
THEN "SELECT * FROM mytable WHERE myID =2814"
WHEN another_condition
THEN "another_select"
END as qry
) t ;

PREPARE query1 FROM @query;
EXECUTE query1;

关于mysql - mysql中结果集的情况,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25787837/

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