MySQL doesn’t allow referring to a table that’s targeted for Delete/update in a FROM clause.
for delete
delete from OrderTable where Itmno = (select Itmno from (SELECT Itmno FROM OrderTable GROUP BY Itmno HAVING count(Itmno)>1 ) as x );
For update
Reference http://www.xaprb.com/blog/2006/06/23/how-to-select-from-an-update-target-in-mysql/
update OrderTable set Itmno = (select Itmno from (select * from OrderTable ) as x where prodtype= 'RET') where prodtype = 'WHL';
www.visli.com
No comments:
Post a Comment