我将保持简洁和简单。我想执行此查询:
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。任何帮助表示赞赏!
答案 0 :(得分: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;
答案 1 :(得分:0)
检查星号是否没有导致您出现问题,或者如果您没有逗号,如果这不起作用,请将别名包含在严重重音符号之间,如下所示:
... QUOTED_PRICE AS `TOTAL_AMOUNT`...