Help: Query INSERT INTO...SELECT...ON DUPLICATE KEY UPDATE
Posted: Fri Nov 26, 2010 8:22 am
Hi
Heres my table structure
TABLE
customerinventory
COLUMN
itemid, itemname,itemqty ,itemtype,total, status, customerid, update
TABLE
withdraw
COLUM
wid, itemid, itemname, itemtype, qty, wtotal, customerid, delivdate, payoption, requestdate, responsedate, status
Im using this query and getting an error of [text]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''itemid', '', itemqty, '', '', '', '', '', '') SELECT qty FROM withd' at line 1[/text]
What Im trying to do is just update the itemqty from customer inventory
Heres my table structure
TABLE
customerinventory
COLUMN
itemid, itemname,itemqty ,itemtype,total, status, customerid, update
TABLE
withdraw
COLUM
wid, itemid, itemname, itemtype, qty, wtotal, customerid, delivdate, payoption, requestdate, responsedate, status
Im using this query and getting an error of [text]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''itemid', '', itemqty, '', '', '', '', '', '') SELECT qty FROM withd' at line 1[/text]
Code: Select all
mysql_query("INSERT INTO customerinventory c ('itemid', '', itemqty, '', '', '', '', '', '')
SELECT qty
FROM withdraw w
WHERE wid = '$wid'
ON DUPLICATE KEY UPDATE itemqty = itemqty - qty") or die(mysql_error());