Error in the consult.. You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'AND fran_status.type != "off" AND location.live_status = "live" GROUP BY t' at line 22SELECT DISTINCT territory.* ,COUNT(DISTINCT connect_locations.id) AS num_locations, GROUP_CONCAT(DISTINCT connect_locations.location_id) AS location_ids, GROUP_CONCAT(DISTINCT fran_status.id) AS status_id, user.avatar AS user_avatar, CONCAT(user.first_name, " ", user.last_name) AS user_name FROM oak_franchise_territories AS territory LEFT JOIN oak_franchise_location_territories AS connect_locations ON (connect_locations.territory_id = territory.id ) LEFT JOIN oak_franchise_locations AS location ON (connect_locations.location_id = location.id) LEFT JOIN oak_franchise_statuses AS fran_status ON (FIND_IN_SET(fran_status.alias, location.status)) LEFT JOIN oak_users AS user ON (territory.modified_by = user.id) WHERE 1 AND connect_locations.location_id = AND fran_status.type != "off" AND location.live_status = "live" GROUP BY territory.id ORDER BY territory.name;