How to Override Drupal Views Query?

markdorison picture markdorison · Nov 15, 2010 · Viewed 13.2k times · Source

How can I replace a Views 3 query with a custom SQL query in code?

Answer

Matt V. picture Matt V. · Jul 22, 2011

From what I understand, you can use hook_views_query_alter to modify the query. I would assume you could also use it to replace the query. Here are a couple hook_views_query_alter examples, to get you started: