I think ollyno1uk means my code ...
From the MySQL 5.0 manual:
Quote:
You can use a subquery for assignment within an UPDATE statement because subqueries are
legal in UPDATE and DELETE statements as well as in SELECT statements. However, you cannot
use the same table (in this case, table t1) for both the subquery's FROM clause and the update
target.
|
... Hmm, thought you couldn't mention the updated columns in the subquery, turns out to be the complete table
My mistake ... Anyway, you could solve this by making a temporary copy of the products table and refer to that one in the subquery.
Let's say you created the temporpary products table and called it TempProd, the complete query would end up looking like this:
Code:
update products
set products_status = 0
where prodcode in
( select t2.PRODCODE
from TempProd as t2
left outer join CSV as t1
on t1.PRODCODE = t2.PRODCODE
where t1.PRODCODE is null )
... and don't forget to get rid of the TempProd table after this update succeeded.
Sorry for the incorrect code the first time ...
Gr,
Yveau