Question
Unwanted Multiple Results with OR in SQL
With the following SQL, I get two of every result. If I take
the AND G.pid
LIKE '%MMColParam3%' OR P.ID LIKE '%MMColParam%' off, I get one of each but
I don't get all the results that I am searching for.
Any Ideas what is causing this?
SELECT P.ProdID, P.ID AS ProductID, P.Name, P.Price, P.ShipCost, PC.gid AS
PCgid, G.gid, G.pid AS Gpid, G.ord, D.PID AS DPID, D.Paragraph
FROM dbo.Products P
INNER JOIN dbo.Groups G ON P.ID = G.pid
INNER JOIN dbo.PCat PC ON G.gid = PC.gid
INNER JOIN dbo.Description D ON G.pid = D.PID
WHERE P.Price IS NOT NULL AND D.Paragraph LIKE '%MMColParam3%' OR P.Name
LIKE '%MMColParam3%' AND G.pid LIKE '%MMColParam3%' OR P.ID LIKE
'%MMColParam%'
LIKE '%MMColParam3%' OR P.ID LIKE '%MMColParam%' off, I get one of each but
I don't get all the results that I am searching for.
Any Ideas what is causing this?
SELECT P.ProdID, P.ID AS ProductID, P.Name, P.Price, P.ShipCost, PC.gid AS
PCgid, G.gid, G.pid AS Gpid, G.ord, D.PID AS DPID, D.Paragraph
FROM dbo.Products P
INNER JOIN dbo.Groups G ON P.ID = G.pid
INNER JOIN dbo.PCat PC ON G.gid = PC.gid
INNER JOIN dbo.Description D ON G.pid = D.PID
WHERE P.Price IS NOT NULL AND D.Paragraph LIKE '%MMColParam3%' OR P.Name
LIKE '%MMColParam3%' AND G.pid LIKE '%MMColParam3%' OR P.ID LIKE
'%MMColParam%'
