子查询
select * from customers where cust_id in (select cust_id from orders where order_num in (select order_num from orderitems where prod_id='TNT2'));
利用子查询进行过滤
select * from customers where cust_id in (select cust_id from orders where order_num in (select order_num from orderitems where prod_id='TNT2'));
作为计算字段使用子查询
select cust_name,(select count(*) from orders where cust_id = customers.cust_id) as num_orders from customers;