2

我将保持简短和简单。我想执行这个查询:

mysql> SELECT ORDER_NUM, NUM_ORDERED * QUOTED_PRICE AS TOTAL_AMOUNT
    -> FROM ORDER_LINE
    -> WHERE TOTAL_AMOUNT > '1000'
    -> ORDER BY ORDER_NUM;
ERROR 1054 (42S22): Unknown column 'TOTAL_AMOUNT' in 'where clause'

我确定这很简单,但我不明白为什么使用别名 TOTAL_AMOUNT 不起作用。任何帮助表示赞赏!

4

2 回答 2

1

尝试这个

mysql> SELECT ORDER_NUM, NUM_ORDERED * QUOTED_PRICE AS TOTAL_AMOUNT
-> FROM ORDER_LINE
-> WHERE NUM_ORDERED * QUOTED_PRICE > '1000'
-> ORDER BY ORDER_NUM;
于 2013-02-13T23:30:37.873 回答
0

检查该星号是否没有给您带来问题,或者您是否缺少逗号,如果这不起作用,请将别名括在重音符号之间,如下所示:

... QUOTED_PRICE AS `TOTAL_AMOUNT`...
于 2013-02-13T23:37:05.870 回答