gpt4 book ai didi

mysql - 静态选择在哪里

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

知道为什么这不适用于 mysql 吗?

SELECT true AS is_valid FROM users WHERE is_valid

我需要以这种方式编写它,因为我正在使用生成查询的框架。

但是我明白了

Unknown column 'is_valid' in 'where clause'

最佳答案

您不能在 where 子句中使用别名,因为查询是从右到左解析的。因此,列的别名一旦从右开始就不知道,从而导致未知列错误。

来自MySql docs :

"A select_expr can be given an alias using AS alias_name. The alias is used as the expression's column name and can be used in GROUP BY, ORDER BY, or HAVING clauses."

关于mysql - 静态选择在哪里,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30193730/

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