SQL problems with COUNT
Posted: Mon Aug 18, 2003 8:29 am
Hi
I am trying to write a query which gets details from a products db, and also the number of associated options from a productoption db.
The SQL I have is like:
What am I doing wrong? MySQL is not really throwing an error which tells me anything, just:
I am trying to write a query which gets details from a products db, and also the number of associated options from a productoption db.
The SQL I have is like:
Code: Select all
$query = ' SELECT products.image_thumb,
products.name,
products.ordercode,
products.short_desc,
products.mrp_price,
products.bigfish_price,
COUNT(productoption.optionId)
FROM products, productoption
WHERE products.category = ' . $this->category . '
AND productoption.productId = products.productId
ORDER BY ' . $sortBy .'
GROUP BY products.productId';Error: You have an error in your SQL syntax near '(productoption.optionId) FROM products, productoption WHERE produc'