MySQL查询 - 未知列

时间:2009-04-13 10:38:19

标签: mysql field alias

我正在尝试运行查询,但是在'where子句'中出现了“未知列'MyField'”错误。

这是我的疑问:

SELECT id, sum(lineValue * quantity) as TotalLine
FROM myTable
WHERE (TotalLine BETWEEN 10 and 500)
group by id 

如何执行类似的查询? 感谢

1 个答案:

答案 0 :(得分:7)

SELECT  id, SUM(lineValue * quantity) as TotalLine
FROM    myTable
GROUP BY
        id
HAVING  TotalLine BETWEEN 10 and 500