About
Pricing
Community
Teams
Start Free Trial
Log in
rgb192
asked on
5/17/2011
select * from orderitems where orderitems123.sku!=orderitems.sku
both tables are of same structure
itemid is primary key
sku is varchar column
select * from orderitems where orderitems123.sku!=orderit
ems.sku
Microsoft SQL Server 2005
13
1
Last Comment
rgb192
8/22/2022 - Mon
Ephraim Wangoya
5/17/2011
What is the question?
rgb192
5/17/2011
ASKER
i want to know the rows in orderitems table
where orderitems123.sku!=orderit
ems.sku
cyberkiwi
5/17/2011
All records in orderitems where the sku does not exist in the other table orderitems123
select a.*
from orderitems a
left join orderitems123 b on a.sku=b.sku
where b.sku is null
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
Ephraim Wangoya
5/17/2011
select orderitems.*
from orderitems
inner join orderitems123 on orderitems123.itemid = orderitems.itemid and orderitems123.sku <> orderitems.sku
Imran Javed Zia
5/17/2011
Please try this:
select * from orderitems
Inner Join orderitems123 On orderitems123.itemid=order
items.item
id
And orderitems123.sku!=orderit
ems.sku
cyberkiwi
5/17/2011
Or if they both have itemid, and you want to match by itemid but where the sku for the itemid-itemid match is not the same:
select a.*
from orderitems a
join orderitems123 b on a.itemid=b.itemid
where a.sku!=b.sku
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
rgb192
5/17/2011
ASKER
orderitems is newer than orderitems123 so orderitems will have more rows which means itemid (primary key)
cyberkiwi
5/17/2011
You can swap sku for itemid in the query I gave earlier
i.e. new rows in orderitems
select a.*
from orderitems a
left join orderitems123 b on a.itemid=b.itemid
where b.itemid is null
rgb192
5/17/2011
ASKER
how to combine
select a.*
from orderitems a
join orderitems123 b on a.itemid=b.itemid
where a.sku!=b.sku
select a.*
from orderitems a
left join orderitems123 b on a.itemid=b.itemid
where b.itemid is null
want rows where sku are different (different skus, or one row doesnt exist)
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
Sharath S
5/17/2011
If orderitems has skus as 1,2,3,4 and orderitems123 has skus as 3.4,5,6. Now based on this sample, which skus are you expecting in the result set?
Sharath S
5/17/2011
type in previous post. Its supposed to be comma between 3 and 4.
If orderitems has skus as 1,2,3,4 and orderitems123 has skus as 3,4,5,6. Now based on this sample, which skus are you expecting in the result set?
ASKER CERTIFIED SOLUTION
cyberkiwi
5/17/2011
THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
rgb192
5/18/2011
ASKER
thanks
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
What is the question?