It seems like most Craft queries contain GROUP BY
id but this seems to clash with a HAVING clause when using the Smart Map plugin.
Where does this come from and is it possible to override/remove this?
Craft CMS Stack Exchange is a question and answer site for administrators, end users, developers and designers for Craft CMS. It only takes a minute to sign up.Sign up to join this community
The HAVING clause comes from this piece of code:
// Modify query $query ->addSelect($haversine.' AS distance') ->having('distance <= '.$filter->range) ;
The variables going into this query modification are:
$haversine- A complex formula which determines the relative distance of each address from the center point.
$filter->range- The maximum search distance. (defaults to 25)
This code exists so that your proximity search results can be sorted by closest locations. It will be triggered any time you chain this into your Twig query:
You can see the full details of how this all ties together in the documentation here:
There should be no conflict with any existing GROUP BY clause... Smart Map does not set or modify that aspect of the query. And there is no inherent conflict between HAVING and GROUP BY, as demonstrated by this w3schools example, which utilizes both in combination.