gpt4 book ai didi

mysql - 在 MySQL SELECT 查询中,我可以在 WHERE 规范中使用我的 "AS column"吗?

转载 作者:太空宇宙 更新时间:2023-11-03 11:16:47 25 4
gpt4 key购买 nike

在我的数据库中,我计算节点之间的距离:

SELECT DISTINCT
dest.name,
AsText(orig.location),
AsText(dest.location),
round((glength(linestringfromwkb(linestring((orig.location), (dest.location)))))) as distance
FROM nodes orig,
nodes dest
WHERE orig.name='GERP'

我要补充

and distance < dest.visibility

在最后,但我被告知距离是一个未知列。

非常感谢任何见解。

最佳答案

使用子查询,那么你只需要输入一次公式(如果你需要改变它,你只需要改变一次)。

SELECT
dest.name,
dest.visibility,
AsText(orig.location),
AsText(dest.location),
distance
FROM (
SELECT DISTINCT
dest.name,
dest.visibility,
AsText(orig.location),
AsText(dest.location),
round((glength(linestringfromwkb(linestring((orig.location), (dest.location)))))) as distance
FROM nodes orig,
nodes dest
WHERE orig.name='GERP'
) AS nodeDistances
WHERE nodeDistainces.distance < visibility

关于mysql - 在 MySQL SELECT 查询中,我可以在 WHERE 规范中使用我的 "AS column"吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4548985/

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