MySQL 学习笔记

MySQL 基本用法和优化

查询

1
2
3
4
5
6
7
SELECT customers.cust_name,
customers.cust_id,
COUNT(orders.order_num) AS num_ord
FROM customers INNER JOIN orders
ON customers.cust_id = orders.cust_id
GROUP BY customers.cust_id
ORDER BY num_ord;