mysql - Unknown column in where clause, but columns is specified in select
问题描述
I am using the following query
SELECT COALESCE(curr_bid, start_bid) AS `bid`, `lot`.*, (SELECT COUNT(id) from bid where lot_id=lot.id) as bids_count FROM `lot` LEFT JOIN (SELECT `lot_step`.`id`, `lot_step`.`lot_id`, max(amount) as curr_bid FROM `lot_step` GROUP BY `lot_step`.`lot_id`) `ls` ON lot.id = ls.lot_id WHERE ((`bid` >= '100') AND (`bid` <= '100000000'))
But I always get Unknown column 'bid' in 'where clause'
. Not sure how can this happen, because I specified the column after SELECT
解决方案
推荐阅读
- android - 如何重命名 androidTest.apk 的 outputFileName?
- sql - 如何在 Begin Try Catch SQL Server 中使用批处理分隔符
- php - laravel 数据透视表返回所有相关数据
- angular - 为什么 Angular 中的 Observable 变量没有实时更新?
- c++ - 如何在派生类上强制实现特定数据类型的构造函数?
- .net - 为什么包含不可能的条件分支会更改此方法的返回值?
- c++ - 如何在 C++ 中从文件中读取某一行并从下面的那一点读取?
- javascript - 如何在外部变量更改时更新对象属性
- javascript - 如何使用 for 循环在 jquery 中增加 id?
- common-lisp - 有没有办法让 hunchentoot:*dispatch-table* 在函数重定义时自动更新?