Skip to content

Instantly share code, notes, and snippets.

@caseydentinger
Created January 28, 2013 18:07
Show Gist options
  • Save caseydentinger/4657707 to your computer and use it in GitHub Desktop.
Save caseydentinger/4657707 to your computer and use it in GitHub Desktop.
$q = 'select sum(op.products_quantity) as quantity
from orders_products op
join (
select distinct orders_id
from orders
where orders_status in (1,5)
) o on o.orders_id = op.orders_id
join (
select distinct products_id
from parts
where parts_id = ' . $dbi->escape($this->id()) . '
) p on p.products_id = op.products_id';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment