View Single Post
Old 07-12-2012, 12:40 PM   PM User | #3
alykins
Senior Coder

 
alykins's Avatar
 
Join Date: Apr 2011
Posts: 1,608
Thanks: 37
Thanked 183 Times in 182 Posts
alykins will become famous soon enough
From what was provided the query should look like this
Code:
SELECT P2.voltage,V.voltage voltage2,count(*) AS KOL 
FROM Lights_America..temp_products P2 
LEFT JOIN  voltage V ON (P2.voltage=V.id) 
LEFT JOIN excludedproducts E ON (E.storeid=SessionID AND E.id=P2.id) 
WHERE ??????????????????????  
GROUP BY P2.voltage,V.voltage 
ORDER BY voltage2
Looking at that I see on problem of two .. in this line
Code:
FROM Lights_America..temp_products P2
and then you also have a table named (supposedly) "voltage" and you are selecting a column named "voltage" ... Are you sure your table is named that? If so try putting [] around the column so these lines would change to
Code:
LEFT JOIN  voltage V ON (P2.[voltage]=V.id)
GROUP BY P2.[voltage],V.[voltage]
but since your join is joining two totally different column names I am guessing you have miss-named the column... your foreign key should have the same name so it should look like
Code:
(P2.id=V.id)
-- or since you should call out the id's a little more detailed
P2.volt_id = V.volt_id
Doing as OldPedant will help though as well since we have no idea what strsql is until after whereStrSql is created
__________________

I code C hash-tag .Net
Reference: W3C W3CWiki .Net Lib
Validate: html CSS
Debug: Chrome FireFox IE
alykins is offline   Reply With Quote