Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mySQL: Select WHERE causes error - why?

I have this query:

SELECT `manufacturers`.*, `languages`.*, COUNT(`products`.`id`) AS productcount
FROM (`manufacturers`)
WHERE `manufacturers`.`flushed` = `0`
JOIN `languages` ON `manufacturers`.`lang` = `languages`.`id`
LEFT OUTER JOIN `products` ON 
`products`.`manuf` =  `manufacturers`.`mid`
GROUP BY manufacturers.id
ORDER BY `languages`.`id` asc, `manufacturers`.`mid` asc;

Without the WHERE row, everything works great, but with it, I get a Error 1064 (Syntax error) thrown in my face. I guess that it has something to do with the actual placement of the WHERE row in the query, so I tried to move it around, but without any luck.

What can I do?

like image 898
Industrial Avatar asked Apr 10 '26 20:04

Industrial


1 Answers

Where goes after the joins, before the group by (joins are considered to be part of the from clause)

like image 120
Donnie Avatar answered Apr 13 '26 14:04

Donnie



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!