我正在寻找以下代码无效的解释。特别是行
lc = MIN(lc)或lc = MAX(lc)
这不仅仅是比较两个数字吗?
SELECT city, lc FROM (SELECT city, LENGTH(city) AS lc FROM station) AS t1 GROUP BY city HAVING lc=MIN(lc) OR lc=MAX(lc)
编辑删除了很多信息,因为人们没有阅读我的问题,而是查看我的代码,然后提供修复,我不需要。我想回答关于SQL概念/理论的问题。
答案 0 :(得分:0)
您可以尝试类似
的内容SELECT city, LENGTH(city) AS lc FROM station
WHERE length(city) in (
SELECT max(length(city)) FROM station
union
SELECT max(length(city)) FROM station
)