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
Post a Comment