Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 SQL Help with Join

Author  Topic 

jrockfl
Posting Yak Master

223 Posts

Posted - 2004-10-07 : 14:24:21
I'm trying to display the the prod_cat and the item_number for the records in the monthlyspecials table. However, it pulls more records then I want. monthlyspecials table only has 30 records.

How can i return just those records and get its prod_cat from the other table? Here is my query.

SELECT OELINHST_SQL.Prod_Cat, monthlyspecials.item_number
FROM monthlyspecials LEFT OUTER JOIN
OELINHST_SQL ON monthlyspecials.item_number = OELINHST_SQL.Item_No

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-10-07 : 14:29:12
SELECT o.Prod_Cat, m.item_number
FROM monthlyspecials m
INNER JOIN OELINHST_SQL o
ON m.item_number = o.Item_No

Tara
Go to Top of Page

mwjdavidson
Aged Yak Warrior

735 Posts

Posted - 2004-10-07 : 14:29:39
If you're returning more records than are in your monthlyspecials table, some or all items must belong to more than one category.

Mark
Go to Top of Page

jrockfl
Posting Yak Master

223 Posts

Posted - 2004-10-07 : 14:48:18
That was the problem, there are duplicates in OELINHST_SQL. Thats line history file, so I can't do anything about that. There is another table I should be using.

Thank you!
Go to Top of Page
   

- Advertisement -