views:

19

answers:

1

I am attempting to build a view with four filters (A, B, C, D). With Views 3 it is possible to select whether you want these filters to be chained with AND statements or OR statements. Is there a way to configure views so as to chain some of them with AND and others with OR?

For example, ending up with a query that is similar to:

SELECT * 
FROM {table} 
WHERE A = 0
  AND B = 0
  AND (C = 1 OR D = 1)
+2  A: 

For views or queries that are usually two approaches:

Now your case is a bit tricky, since you don't want to end up doing

SELECT * 
FROM {table} 
WHERE A = 0
AND B = 0
AND C = 1
OR D = 1

So you probably want to go with the hook.

The views query builder can handle OR queries, so I'm pretty sure you can choose how you want it. But the documentations is limited, and I haven't personal experience doing just this, so you might need some trial and error before you get it just right.

googletorp
+1 for hook_views_query_alter
Andrew Sledge

related questions