Hello friends,
I'm an SQL newbie and I have to change few things in our customer-repair-database.
Here is what I have:
There is a REPAIR table and it has a STATUS column, where "1" means repair not done, and "2" means repair is done.
There is also an ITEM table with the column ITEMSTATUS, where "1" also means done, and "2" means not done.
Unfortunately, there were some mistakes made by emplyees and now there are items in the
ITEM table with
ITEMSTATUS "1" even tough
ITEMSTATUS should be set to
"2" because the belonging repair is already set to
"2" (done).
What I have tried:
Here is an sql query I wrote to show me all items where the status sould be set to "2":
SELECT REPAIR.REPAIRID,
REPAIR.STATUS,
ITEM.REPAIRID,
ITEM.ITEMID,
ITEM.ITEMSTATUS
FROM REPAIR
LEFT JOIN ITEM ON REPAIR.REPAIRID = ITEM.REPAIRID
WHERE REPAIR.STATUS = '2' AND ITEM.ITEMSTATUS = '1'
This sql query shows me all the items where I need to set ITEMSTATUS to "2". Since there are over 2000 items shown I'd like to avoid doing that manually :).
Now I don't know how to use the INSERT INTO statement with the described query and I hope someone could help me.