Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query Comparison

Status
Not open for further replies.

evr72

MIS
Dec 8, 2009
265
0
0
US
Hello,

I have two table one called items and the other itemscomp

my items table contains all my items it only has 3 fields

Itemnum, component and qty this shows something like this

Code:
Itemnum     component       qty
0001        abc              .96
0001        xyz              .04
0045        abc              .75
0045        bb2              .25

the itemscomp has the same exact fields, but the item numbers are different

Code:
Itemnum     component         qty
TM01         abc              .96
TM01         xyz              .04
ASM5         abc              .75
ASM5         bb2              .25

what I am trying to do is get all the part numbers who's components are the same as the "itemscomp" table


I did a relational query
Code:
SELECT [items].itemnum, [items].component, [items].qty, itemscomp.itemnum, itemscomp.component, itemscomp.qty
FROM itemscomp LEFT JOIN [items] ON itemscomp.component = [items].component

But this gives me something like this
Code:
Itemnum     component       qty	
0001        abc              .96	TM01         abc              .96
0001        abc              .96	ASM5        abc              .96
0045        abc              .75	TM01         abc              .96
0045        abc              .75	ASM5         abc              .75

and I would like to get something like this
Code:
0001        abc              .96	TM01         abc              .96
0001        xyz             .04	TM01         xyz              .04
0045        abc              .75	ASM5         abc              .75
0045        bb2              .25	ASM5         bb2              .25


any help is much appreciated.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top