输入banner图图片脚本导航/分类

mysql(3)

1.子查询

 select cust_id from orders
 where order_num in (select order_num from orderitems 
                                where prod_id=‘TNT2‘)

 

SELECT cust_id,cust_name,(select count(*) from orders where orders.cust_id=
customers.cust_id)  from customers;

等效于select q.cust_id,q.cust_name ,count(order_num) from  orders p right join  customers q  
on p.cust_id=q.cust_id group by q.cust_id

2.等值连接(内部连接)

mysql(3)

标签: