mysql - Multiply in update subquery select -


i'm trying update table based on 2 select subquery multipied produce value harga column

here code :

update bahanmakanan  set harga = (select hargasatuan detail_bahanmakanan      idbahanmakanan = "bm01")* (select jumlah bahanmakanan      idbahanmakanan = "bm01")  idbahanmakanan = "bm01" ; 

the error message return

error code: 1093. can't specify target table 'bahanmakanan' update in clause 

you can using join,

update  bahanmakanan         inner join detail_bahanmakanan b             on a.idbahanmakanan = b.idbahanmakanan  set     a.harga = a.jumlah * b.hargasatuan    a.idbahanmakanan  = 'bm01' 

please backup first database before executing statement.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

javascript - Clean way to programmatically use CSS transitions from JS? -

android - send complex objects as post php java -