[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 184
  • Last Modified:

My Select Statement is resulting in duplicate records being produced...

Help,


My Select Statement is resulting in duplicate records being produced...

Think it may be something to do with my joins????

Thank you


Select 
P.ID, 
P.[Product-Name], 
LEFT(P.[Product-Description],40)+'..' AS Description, 
Case When P.[Display-TGI-Special-Price]='Y' then DP.[Special-Price] Else DP.[Normal-Price] end AS Price, 
Case When P.[Display-TGI-Special-Price]='Y' then DP.[Normal-Price] end AS  OriginalPrice, 
I.Image, 
P.SKUCode 
from dbo.[Direct-Product] P 
inner join dbo.[Direct-Product-Image] I on I.ProductID = P.ID 
inner join dbo.[Direct-Product-Price] DP on DP.[Product-ID] = P.ID 
left join dbo.[Direct-Product-Category] DPC on DPC.[Product-ID] = P.ID 
left join dbo.[Direct-Category] C on C.ID = DPC.[Category-ID] 
inner join dbo.[Nominal-Codes] NC ON P.NominalCodeID = NC.ID 
Where (C.[Category-label] LIKE 't' OR P.[Product-Name] LIKE 't' OR P.SKUCode LIKE 't'
OR P.[Product-Description] LIKE 't') 
AND P.StockCount >= 1 AND P.[Display-TGI-Direct] = 'Y' 
AND I.[Default-Image] = 'Y'

Open in new window

0
garethtnash
Asked:
garethtnash
2 Solutions
 
BartVxCommented:
Try

SELECT DISTINCT
0
 
Lee SavidgeCommented:
Undoubtedly it will be because of the joins.

Firstly try using select distinct and see what happens.
0
 
garethtnashAuthor Commented:
thanks both
0

Featured Post

NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now