我有一个开始于...的查询]
SELECT session_id, time, quantity, teacher, sum(time+(quantity*60*60*60)) AS end FROM my_table WHERE end > 1582214400
我收到PDO例外...
column not found: 1054 Unknown column 'end' in 'where clause'
为什么PDO / MySQL会给我这个错误?什么是计算end的正确语法,因此我可以在WHERE子句中使用它?
您不能在select
子句中使用where
中的别名。使用having
SELECT session_id, time, quantity, teacher, sum(time+(quantity*60*60*60)) AS end FROM my_table having end > 1582214400