美文网首页
exists,not exists,in

exists,not exists,in

作者: 柚一西_ | 来源:发表于2022-02-07 17:26 被阅读0次

    1、exists子查询的功能是判断返回结果中是否有数据行

    SELECT DISTINCT goods_name FROM goods WHERE EXISTS (SELECT * FROM brand WHERE cat_id = goods.cat_id AND name='索尼');

    2、in查询数据是否有匹配的

    SELECT DISTINCT goods_name FROM goods WHERE cat_id IN(SELECT cat_id  FROM brand WHERE cat_id = goods.cat_id AND name='索尼');

    相关文章

      网友评论

          本文标题:exists,not exists,in

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