Mysql基础第十七天,使用子查询
Posted 2019ab
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Mysql基础第十七天,使用子查询相关的知识,希望对你有一定的参考价值。
子查询
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;
以上是关于Mysql基础第十七天,使用子查询的主要内容,如果未能解决你的问题,请参考以下文章