mysql join

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
m2babaey
Forum Contributor
Posts: 364
Joined: Sun May 20, 2007 9:26 am

mysql join

Post 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'
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: mysql join

Post 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.
Post Reply