不好意思,我想问下大家,为什么
select count(*) from data_clean.content_all_raw as a
where exists(
select * from crawler.ag03_songs as b
where a.content=b.name and a.performer=b.artist
);

select count(*) from data_clean.content_all_raw as a
join crawler.ag03_songs as b
on a.content=b.name and a.performer=b.artist;
的结果不同呢?想请大家指点一下,我只知道join是用来显示两个表的数据,exists是用来显示一个表的数据的,

解决方案 »

  1.   

    select count(*) 
    from data_clean.content_all_raw as a 
    where exists( 
    select * from crawler.ag03_songs as b 
    where a.content=b.name and a.performer=b.artist 
    ); select count(*) 
    from data_clean.content_all_raw as a join crawler.ag03_songs as b 
    on a.content=b.name and a.performer=b.artist; 第二种 做了JOIN,如果 (content performer)对应的(name ,artist)为1 对 N,对会针对同一条 content_all_raw 中的记录产生多条JOIN后的记录。自然此时的count(*)会大于第一种
      

  2.   

    使用exists查询的结果比用join查询的结果少
      

  3.   

    1、贴记录;
    2、JOIN中多出的记录有什么特征
      

  4.   

    您能说的再详细点吗?能不能举个列子说明exists和join的查询结果为什么会不同