php - MySQL "REPLACE INTO" using a SELECT to pull one field -
php - MySQL "REPLACE INTO" using a SELECT to pull one field -
i've got mysql database has 2 tables (actually many more). first table links product's sku number arbitrary id. there sec table records end of day inventory each item based on id. when inventory changed reasons other sales, there record placed in sec table boolean set false. allows me new number not valid vector sales previous, next day's sales.
there syntax error in code. i'm still student, , appreciate help in explaining how kind of update work. know first value needs come select statement?
here current mysql statement:
replace sales (`itemid`, `date`, `qty`, `price`) values ([itemid], curdate(), [qty], 0.00) select itemid item `sku` = [sku]
replace works insert, except if there row same key trying insert, deleted on replace instead of giving error.
you can either specify arguments directly:
replace sales( `item_id`, `date`, `qty`, `price` ) values( 15, '2012-01-01`, 5, '120.00' ) or specify them using select:
replace sales( `item_id`, `date`, `qty`, `price` ) select item_id, date, qty, cost sales_to_accept sales_id = 721 you cannot mix both types of syntax in 1 query.
but there nil stopping adding constant values columns select:
replace sales( `item_id`, `date`, `qty`, `price` ) select item_id, curdate(), 5, '74.00' item `sku` = 'something' php mysql
Comments
Post a Comment