美文网首页
使用子查询

使用子查询

作者: 骑着白龙马的猪八戒 | 来源:发表于2019-08-05 10:17 被阅读0次

    select order_num from orderitems where prod_id = 'tnt2';

    select cust_id from orders where order_num in ('20005','20007');

    等价于

    select cust_id from orders where order_num in ( select order_num from orderitems where prod_id = 'tnt2');

    select cust_name,cust_contact from customers where cust_id in

        -> (select cust_id from orders where order_num in (

        ->  select order_num from orderitems where prod_id = 'tnt2'));

    相关文章

      网友评论

          本文标题:使用子查询

          本文链接:https://www.haomeiwen.com/subject/sxqgrctx.html