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.
| 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_IDFROM 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_NOWHERE ((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. |
 |
|
|
tosscrosby
Aged Yak Warrior
676 Posts |
|
|
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. |
 |
|
|
|
|
|
|
|