ZUBU ZUBU - 2 months ago 13
MySQL Question

SQL Syntax error SELECT

I'm very new to MySQL and I'm attempting to sort out a query issue. I'm running a cron job which updates one database from another but I'm getting the following error:


#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


Here is the query I am trying to execute:

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)


From what I know it seems to be an issue with table names and restricted variables in mysql but so far I haven't been able to quote out the right table names. Any help would be greatly appreciated.

Answer

You're missing something after 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)