简体   繁体   中英

Mysql error: violation: 1052 Column 'created_at' in where clause is ambiguous'

I am getting the issue:

Integrity constraint violation: 1052 Column 'created_at' in where clause is ambiguous'

but the table sales_flat_order_grid have created_at Column

SELECT DISTINCT main_table.*, 
                blacklist.entity_id AS marked 
FROM   sales_flat_order_grid AS main_table 
       LEFT JOIN (SELECT main_table.* 
                  FROM   plugincompany_blacklist_item AS main_table 
                  WHERE  ( order_id != '0' ) 
                  GROUP  BY order_id) AS blacklist 
              ON main_table.entity_id = blacklist.order_id 
WHERE  ( created_at >= '2016-11-03 00:00:00' 
         AND created_at <= '2016-11-26 23:59:59' ) 

Both tables have a created_at clause. So mysql does not know which one to take. You need to be clear about that:

WHERE  ( main_table.created_at >= '2016-11-03 00:00:00' 
     AND main_table.created_at <= '2016-11-26 23:59:59' ) 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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