Skip to content

Instantly share code, notes, and snippets.

@kevinchampion
Created January 3, 2013 03:59
Show Gist options
  • Save kevinchampion/4440661 to your computer and use it in GitHub Desktop.
Save kevinchampion/4440661 to your computer and use it in GitHub Desktop.
Query optimization
SELECT
n.nid as nid
FROM node n
INNER JOIN content_field_revenue_unit_ref r ON r.nid = n.nid
INNER JOIN content_type_tax_reporting_units u ON u.nid = r.field_revenue_unit_ref_nid
LEFT JOIN content_type_tax_sales_report t ON n.nid = t.field_sales_revenue_ref_nid
AND t.field_sales_activity_month_value = 12
AND t.field_sales_activity_year_value = 2012
WHERE n.type = 'tax_revenue_source'
AND u.field_reporting_unit_status_value = 'A'
AND n.status = 1
AND t.nid IS NULL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment