I'm new to PL/SQL. I've created a table called orders which has a pk as orders_id and a products table with a pk as products_id. Both are numbers 1 through 10. In the orders table is a column called item_name, which I want to merge into the products column called item_name.
This is what I have tried:
MERGE INTO products
USING (
SELECT item_name
FROM orders)
ON (orders.order_id = products.product_id)
WHEN MATCHED THEN
UPDATE SET
products.item_name = orders.item_name
AND
MERGE INTO products
USING (
SELECT item_name
FROM orders)
ON (products.product_id=orders.order_id )
WHEN MATCHED THEN
UPDATE SET
products.item_name2 = orders.item_name
I keep getting the error "ORA-00904: "ORDERS"."ORDER_ID": invalid identifier". I've checked order_id is a NUMBER the same as the product_id. I have also created a column in products called item_name2, but that didn't work either. What does the error mean? Any help is appreciated, thank you.
Here's how.
Sample tables:
Updating
products.item_namefrom theorderstable:Result: