Love to live, and live to love

When it can be simple, keep it simple. When it can’t, make it simple!

Archive for Juni 19th, 2014

Update table from the other field of the same table

Posted by ardnahc pada 19 Juni, 2014

hell yeah.. got some tips from stackoverflow about how to update record from the other record from the same table. here is my code:

 

update `tblname` as dudul, (select id,record2 from `air` where record3=’2014-06′) AS dudul2
set dudul.record1 = dudul2.record2
where dudul.record3=’2014-07′ and dudul.id=dudul2.id;

 

thanks so.

ref: http://stackoverflow.com/questions/45494/mysql-error-1093-cant-specify-target-table-for-update-in-from-clause

Posted in Diary | Dengan kaitkata: , , , , | Leave a Comment »