[thelist] mysql UPDATE SELECT query

Bojan Tesanovic btesanovic at gmail.com
Tue Apr 1 09:34:41 CDT 2008


Hi there,
I have a SQL problem , I am trying to update some field from one  
table and assign the value to that filed with SELECT statement
here is example

update ads set img_1_small= (select  img_1_small from ads where  
id=37) where img_1_small is NULL;


but mysql return
Error Code : 1093
You can't specify target table 'ads' for update in FROM clause
(0 ms taken)



is there a way to do this with one SQL query ?


Bojan Tesanovic
http://www.carster.us/







More information about the thelist mailing list