I want to merge SQL query of two views using Union keeping contextual filter intact.Please let me know as how to achieve this in Views UI or using hook like hook_views_query_alter/hook_views_pre_execute.

Comments

WorldFallz’s picture

Can't be done through the UI. You need to use hook_views_query_alter in a custom module. See http://api.drupal.org/api/views/views.api.php/function/hook_views_query_... for more info.

tm0032938’s picture

Can I get an example or link in Internet where the union statement is used in hook_views_query_alter?
The link provided by you contains example related to Grouping and sorting inside view.

WorldFallz’s picture

i don't know of a union specific example, but views just uses the d7 db api: http://api.drupal.org/api/drupal/includes!database!select.inc/function/S...