The Idea of the Query is to get all the entries where the seo_path_info
has duplicates and the corresponding product is set to active.
My Query is:
SELECT `seo_path_info`,COUNT(`seo_path_info`)
FROM `shopware`.`seo_url` seo
GROUP BY `seo_path_info`
HAVING COUNT(`seo_path_info`)>1
LEFT JOIN product p ON p.id = seo.foreign_key WHERE p.active = '1';
And the corresponding Error:
Query 1 ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘LEFT JOIN product p ON p.id = seo.foreign_key WHERE p.active = ‘1” at line 5
3
Answers
JOIN
comes afterFROM
but beforeWHERE
, andWHERE
comes beforeGROUP BY
:Basic SQL syntax is
The solution is:
where caluse can’t be before group by or having clause. The following would be the correct order
OR