MySQL SELECT from two tables with COUNT -
i have 2 tables below:
table 1 "customer" fields "cust_id", "first_name", "last_name" (10 customers) table 2 "cust_order" fields "order_id", "cust_id", (26 orders)
i need display "cust_id" "first_name" "last_name" "order_id"
to need count of order_id
group cust_id
list total number of orders placed each customer.
i running below query, however, counting 26 orders , applying 26 orders each of customer.
select count(order_id), cus.cust_id, cus.first_name, cus.last_name cust_order, customer cus group cust_id;
could please suggest/advice wrong in query?
you try one:
select count(cus_order.order_id), cus.cust_id, cus.first_name, cus.last_name cust_order cus_order, customer cus cus_order.cust_id = cus.cust_id group cust_id;
Comments
Post a Comment