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
 General SQL Server Forums
 New to SQL Server Programming
 Duplicate rows

Author  Topic 

gudushen
Starting Member

16 Posts

Posted - 2008-10-29 : 16:18:51
Hi, I have this query that keeps giving me the same data twice for each entry. It's probably because it's getting the same entry in both the iv_master and eannet table. Is there anyway for me to filter this and only retrieve the entry from eannet table?

here's the query:
SELECT IV_Master.EAN_UPC_NO AS iv_master_upc,
ean.EAN_UPC_NO AS ean_upc,
ean.MEMBER_ID,
ean.PACK_MATERIAL_ID,
ean.PACK_TYPE_ID,
ean.DATE_ADDED,
ean.DATE_ENDED,
ean.DATE_UPDATED,
ean.BRANDS,
ean.NAME,
ean.VARIANTS,
ean.PACK_SIZE,
ean.DESCRIPTION,
ean.COMMENTS,
ean.BRANDS_FR,
ean.NAME_FR,
ean.VARIANTS_FR,
ean.DESCRIPTION_FR,
ean.CSDF_NUMBER,
ean.DATE_IMAGED,
ean.DATE_COMPLETED,
ct.CATEGORY_ID
FROM eannet AS ean
INNER JOIN IV_Master
ON ean.DATE_UPDATED > IV_Master.DATE_UPDATED AND ean.EAN_UPC_NO = iv_master.EAN_UPC_no
INNER JOIN SAMPLE_INVENTORY AS inv
ON inv.EAN_UPC_NO = ean.EAN_UPC_NO
INNER JOIN SAMPLE_RECEIPTS AS recp
ON inv.SAMPLE_RECEIPTS_ID = recp.SAMPLE_RECEIPTS_ID
INNER JOIN CATEGORY_LINK AS ct
ON ct.EAN_UPC_NO = ean.EAN_UPC_NO
WHERE ((recp.IMAGE_REQUIRED = 'COM3') OR (recp.IMAGE_REQUIRED = 'COM4') )


thanks in advance

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2008-10-29 : 16:35:13
quote:
It's probably because it's getting the same entry in both the iv_master and eannet table.

I don't think so. A join is used to find MATCHING rows, so it's not a problem when there are matching rows.

Try select DISTINCT...

Webfred


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

tosscrosby
Aged Yak Warrior

676 Posts

Posted - 2008-10-29 : 17:03:20
If you can supply table layouts and data samples, you'll probably receive a quick, accurate response - IMO

Edit - See Brett's excellent article on how to post and receive accurate replies:
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Terry
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-30 : 03:57:47
its because you've 1 to many relationship existing between tables. but to fix it, we need to know how data exists in your tables. So please post the sample data and output you need as per link above.
Go to Top of Page
   

- Advertisement -