Page 1 of 1

mysql join

Posted: Wed Sep 03, 2008 4:04 am
by m2babaey
Hi
I have tables producs abd prod_subcat but i can't join the with this code:
I echoed the query and it is:

Code: Select all

SELECT * FROM products pp,prod_subcat ps WHERE (`pp.productID` LIKE 
'%40%' OR `productName` LIKE '%40%' OR `productDescription` LIKE '%40%' 
OR `productColour` LIKE '%40%' OR `productID` LIKE '%%' OR `productName` 
LIKE '%%' OR `productColour` LIKE '%%' ) AND ((ps.subcategoryID='8' AND 
ps.productID=pp.productID ) OR (ps.subcategoryID='7' AND 
ps.productID=pp.productID ))ORDER BY productID LIMIT 0,50
current error:
Unknown column 'products.productID' in 'where clause'

Re: mysql join

Posted: Wed Sep 03, 2008 5:15 am
by onion2k
You need to sort out your backticks. Things like `pp.productID` will look for a column called pp.productID. It should be pp.`productID`. You're also only using the table alias on some of your columns. Make it clear what every single column is. And lastly, check that the column called productID actually exists in the products table.