Question resolved
I have two tables, orders and customers, and I'd like to find all customers where orders is greater than 0.
I currently use two queries:
SELECT * FROM customers
and
SELECT count(id)
FROM orders
WHERE customer='CUSTOMER_VALUE'
AND siteid='siteid'
I'd like to turn this into one query, so it finds all customers where they've placed one or more orders in the store.
I tried the following, but it doesn't work:
SELECT c.*,
COUNT(o.customer) AS numOrders
FROM customers c,
orders o
WHERE o.siteid= 'calico'
AND o.customer=c.email
(it only gives one result, which is customer ID 1).
I only need to find the orders value, and a few values from the customers table.
The customer field in orders and the id field in customers are the same value (ie order 1 was placed by customer 5, customer id 5 is "John").
Is there any way to do this?
The current way works, but it would be greatly inefficient if there was to be a large amount of customers.
order.customerstore thecustomer.idor thecustomer.email?