当前位置:Gxlcms > 数据库问题 > mysql(3)

mysql(3)

时间:2021-07-01 10:21:17 帮助过:2人阅读

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)

标签:

人气教程排行