Home > Enterprise >  UPDATE from SELECT: Join Method
UPDATE from SELECT: Join Method

Time:12-21

I am using this

UPDATE stockout_details
SET 
stockout_details.chaloutinv=stockin_details.inv_cha
FROM stockout_details 
INNER JOIN stockin_details
ON stockin_details.marka = stockout_details.marka and stockin_details.purchi = stockout_details.purchi and 
stockin_details.chalan = stockout_details.chalan and stockin_details.room = stockout_details.room and
stockin_details.rack = stockout_details.rack 

and the error is

UPDATE stockout_details
SET 
stockout_details.chaloutinv=stockin_details.inv_cha
FROM stockout_details 
INNER JOIN
'stockin_details'
ON stockin_details.marka = stockout_details.marka and stockin_details.purchi = stockout_details.purchi and 
stockin_details.chalan = stockout_details.chalan and stockin_details.room = stockout_details.room and
stockin_details.rack = stockout_details.rack;

MySQL said: Documentation

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'FROM stockout_details
INNER JOIN
'stockin_details'
ON stockin_details.mar...' at line 4

CodePudding user response:

UPDATE with JOIN should looks like:

UPDATE T1,T2
INNER JOIN T2 ON T1.C1 = T2.C1
SET T1.C2 = T2.C2,
      T2.C3 = expr
WHERE condition

So you don't need to add FROM table

  • Related