I've been searching the web all night trying to find an answer to this... No luck so far. All other solutions I have tried have resulted in syntax errors.
I'm trying to run an update statement to update location_id values for a selection items. I have two tables: an existing INVENTORY table and a TEMP_INV table containing a subset of item_id values and new location_id values. I want to update the current location_id values in the INVENTORY table with the new location_id values in the TEMP_INV table, but only for the items in the TEMP_INV table.
INVENTORY table
item_id location_id
123453 12-099
123454 12-100
123456 12-101
123457 12-102
123458 12-103
TEMP_INV table
item_id location_id
123456 13-101
123457 13-102
123458 13-103
Desired results:
INVENTORY table
item_id location_id
123453 12-099
123454 12-100
123456 13-101
123457 13-102
123458 13-103
I'm running the below update statement and receiving the error "284: A subquery has returned not exactly one row."
UPDATE inventory
SET location_id =
(SELECT location_id
FROM temp_inv
WHERE item_id=item_id)