I am having difficulty coming up with a valid syntax, and I don't even know if it is possible.
I have two tables: orders and order_item
orders has information like customer_id, date_purchased and so on.
What I need to do is to get all (*) fields from orders, and (SUM(order_item.quantity) WHERE orders.id = order_item.orders_id) all in a single sql command.
Basically the syntax I am currently trying to get to work is:
SELECT a.*, SUM(b.quantity) FROM orders AS a, order_item AS b WHERE a.company_id = 3 AND a.id = b.orders_id
I have a feeling that I need to do a LEFT JOIN as a nested statement... Any ideas?