gpt4 book ai didi

mysql - SELECT cols, (SELECT 内部查询) AS innercol FROM 表 WHERE innercol 某事

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

只要我避免 WHERE stream_json ... 这可以修复还是需要 JOINS?

SELECT id, stuff,
(SELECT count(*)
FROM inner_table
WHERE inner_table.movie_id = outer_table.id)
AS stream_json
FROM outer_table
WHERE stream_json != 0

最佳答案

您可以使用HAVING来访问使用WHERE子句无法接受的自定义别名

SELECT (SELECT count(*) FROM inner_table
WHERE inner_table.movie_id = outer_table.id) AS stream_json
FROM outer_table HAVING stream_json != 0

See this for reference

关于mysql - SELECT cols, (SELECT 内部查询) AS innercol FROM 表 WHERE innercol 某事,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19134386/

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