I'm trying to debug an issue with views grouped filter using locations.
the grouped filters work fine using an OR clause but returns no results when using an AND clause.

using devel module i've taken the sql query to debug it directly in phpmyadmin sql field.

the query looks like this:
SELECT node.title AS node_title, node.nid AS nid FROM node node
LEFT JOIN location_instance location_instance ON node.vid = location_instance.vid
LEFT JOIN location location ON location_instance.lid = location.lid
WHERE ((location.city LIKE '%beijing%') OR (location.city = '%lhasa%'))

and returns the correct results

however as soon as i change the last OR to and AND like so:
SELECT node.title AS node_title, node.nid AS nid FROM node node
LEFT JOIN location_instance location_instance ON node.vid = location_instance.vid
LEFT JOIN location location ON location_instance.lid = location.lid
WHERE ((location.city LIKE '%beijing%') AND (location.city = '%lhasa%'))

no results are returned. there are nodes which contain both location values

using only one of either location value also returns results: eg
SELECT node.title AS node_title, node.nid AS nid FROM node node
LEFT JOIN location_instance location_instance ON node.vid = location_instance.vid
LEFT JOIN location location ON location_instance.lid = location.lid
WHERE ((location.city LIKE '%beijing%'))

or
SELECT node.title AS node_title, node.nid AS nid FROM node node
LEFT JOIN location_instance location_instance ON node.vid = location_instance.vid
LEFT JOIN location location ON location_instance.lid = location.lid
WHERE ((location.city = '%lhasa%'))

any ideas would be really appreciated.

I'm trying to debug the issue http://drupal.org/node/1941402

Comments

irishdan’s picture

Issue summary: View changes

edited final query

MustangGB’s picture

Status: Active » Closed (outdated)