我在弄清楚如何解决此查询时遇到了麻烦。
这是我的CodeIgniter代码
return $this->db
->select('vehVin, vehMake, vehModel, seller, dealership, buyer, logistics.warehouseName, transportDate, car_tracking.keys, car_tracking.window')
->where('transportDate <', $yesterday)
->where('(car_tracking.keys', "'0'", FALSE)
->or_where("car_tracking.stickers = '0')", NULL, FALSE)
->join('logistics', 'logistics.stockid = vehicles.stockid')
->join('car_tracking', 'car_tracking.stockid = logistics.stockid')
->get('vehicles')
->result();
这是我得到的错误
Unknown column 'car_tracking.stickers' in 'where clause'
`SELECT `vehVin`, `vehMake`, `vehModel`, `seller`, `dealership`, `buyer`, `logistics`.`warehouseName`, `transportDate`, `car_tracking`.`keys`, `car_tracking`.`window`
FROM (`vehicles`)
JOIN `logistics` ON `logistics`.`stockid` = `vehicles`.`stockid`
JOIN `car_tracking` ON `car_tracking`.`stockid` = `logistics`.`stockid`
WHERE `transportDate` < '2013-11-25'
AND (car_tracking.keys = '0' OR car_tracking.stickers = '0')`
提前感谢您的帮助!
最佳答案
确保car_tracking.stickers存在。
我还考虑将sql查询设为原始。因为codeigniter的查询生成器有很多问题。当它们一起使用时,它不能处理大多数查询条件。