2016-09-25 138 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