2016-09-25 134 views
0

我对MySQL很陌生,我试图解决一个查询问题。我运行一个cron作业,这从另一个更新一个数据库,但我发现了以下错误:SQL语法错误SELECT

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'and a.entity_id not in (select magento_order_id from mg_asul' at line 4

这里是我试图执行查询:

select entity_id 
from mg_sales_flat_order a 
where status = 'complete' 
      and a.entity_id > 
      and a.entity_id not in 
       (select magento_order_id 
       from mg_asulpunto_unicentaopos_order_item b 
       where b.magento_order_id=a.entity_id) 

据我所知它似乎是一个表名和在mysql中受限制的变量的问题,但到目前为止我还没有能够引用正确的表名称。任何帮助将不胜感激。

+2

'和a.entity_id>'什么? –

+0

'entity_id'应该大于什么?编译器无法读取您的想法;) –

回答

1

你失踪后and a.entity_id >

select entity_id 
from mg_sales_flat_order a 
where status = 'complete' 
     and a.entity_id >    /* Specify the value after > sign */ 
     and a.entity_id not in 
      (select magento_order_id 
      from mg_asulpunto_unicentaopos_order_item b 
      where b.magento_order_id=a.entity_id) 
+0

谢谢总是感觉。就像我说的,我对MySQL很陌生。干杯 – ZUBU