Love to live, and live to love

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

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

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

 
%d blogger menyukai ini: