繁体   English   中英

MySQL左外部联接列不存在-CodeIgniter DataMapper ORM

[英]Mysql left outer join column does not exist - CodeIgniter DataMapper ORM

我正在运行以下查询,该查询是由CodeIgniter的DataMapper ORM生成的,因为我尝试查询order_product/order/order_status形式的深层关系:

SELECT `order_products`.*
FROM (`order_products`)
LEFT OUTER JOIN `orders` orders ON `orders`.`id` = `order_products`.`order_id`
LEFT OUTER JOIN `order_statuses` order_order_statuses ON `order_order_statuses`.`id` = `orders`.`order_status_id`
WHERE `order_products`.`sku` IN ('SYB-SAMPLETEST8', 'Copy of SYB-SAMPLE#B')
AND `order_products`.`deleted` =  0
AND `orders`.`ext_created_on` >= '2014-05-05'
AND `order_products`.`deleted` =  0
AND `orders`.`ext_created_on` <= '2014-05-21'
AND `orders`.`deleted` =  0
AND `order_statuses`.`deleted` =  0
AND `order_order_statuses`.`sales_data` =  1

我收到以下错误:

ERROR 1054 (42S22): Unknown column 'order_statuses.deleted' in 'where clause'

我的order_statuses表的架构如下:

+-------------+--------------+------+-----+-------------------+----------------+
| Field       | Type         | Null | Key | Default           | Extra          |
+-------------+--------------+------+-----+-------------------+----------------+
| id          | int(11)      | NO   | PRI | NULL              | auto_increment |
| ext_id      | int(11)      | YES  |     | NULL              |                |
| ext_type_id | int(11)      | YES  |     | NULL              |                |
| name        | varchar(255) | YES  |     | NULL              |                |
| sales_data  | tinyint(1)   | YES  |     | 0                 |                |
| deleted     | tinyint(1)   | NO   |     | 0                 |                |
| created_on  | timestamp    | NO   |     | CURRENT_TIMESTAMP |                |
+-------------+--------------+------+-----+-------------------+----------------+

即使存在已删除的列,为什么仍会收到此错误?

因为您将其别名为order_order_statuses。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM