-
Sql compare tables and insert missing data
Compare Tables ITEM_A/I_ID with ITEM/I_ID, filtering so that you are only addressing item IDs that start with 25*. Make a list of ITEM lines that ARE NOT in ITEM_A
From that list, create new rows in ITEM_A inserting the following fields
ITEM ITEM_A
a. I_ID I_ID
b. ITEM_R_ID ITEM_R_ID
c. ITEM_DESC SALES_DESC
-
Homework, huh?
Okay ... there are a lot of unknowns in those business specs - like datatypes, complete table structures, etc - so, here you have a template - after all, your instructor really wants you to do at least part of it, isn't it?
Code:
insert
into
item_a
select
*
from
(
select *
from item
where i_id like '25%'
minus
select *
from item_a
where i_id like '25%'
);
Pablo (Paul) Berzukov
Author of Understanding Database Administration available at amazon and other bookstores.
Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|