我想选择下订单最多的客户:
我有 2 张桌子:
CREATE TABLE customers(
customerid INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
NAME CHAR(50) NOT NULL,
address CHAR(100) NOT NULL,
city CHAR(30)NOT NULL
);
CREATE TABLE orders(
orderid INT UNSIGNED NOT NULL,
customerid INT UNSIGNED NOT NULL,
);
这就是我想要做的:
SELECT customers.customerid, customers.name,orders.orderid, COUNT(customerid)
AS CostumerCount
FROM customers
INNER JOIN orders
ON customers.customerid=orders.orderid;
我怎么能做这个?