Skip to content

Instantly share code, notes, and snippets.

@tolyod
Last active April 3, 2020 20:09
Show Gist options
  • Save tolyod/693e96d7f7fa8d45b91ff55cce65deae to your computer and use it in GitHub Desktop.
Save tolyod/693e96d7f7fa8d45b91ff55cce65deae to your computer and use it in GitHub Desktop.
SELECT p.id,
p.items,
Ifnull(Sum(s.stock), 0) AS sumstock
FROM phpshop_products p
left JOIN
(
select warehouse_id,
enabled,
product_id,
stock
from phpshop_modules_warehouse_stocks
where warehouse_id IN ( 0 )
AND enabled = '1'
) s
ON p.id = s.product_id
WHERE p.id IN ( 1288, 863 )
group by p.id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment