有A,B两个表
我selet count(1) from a 比如是10000条数据
我selet count(1) from a left join b .... 这时候为什么比10000条多呢,,,不是应该也是10000条数据吗
------解决方案--------------------
- SQL code
create table test1( id int, name varchar(10) ) INSERT INTO test1 VALUES (1,'a')INSERT INTO test1 VALUES (1,'b')INSERT INTO test1 VALUES (2,'c')INSERT INTO test1 VALUES (3,'d')INSERT INTO test1 VALUES (4,'e')create table test2( id int, name varchar(10) ) INSERT INTO test2 VALUES (1,'q')INSERT INTO test2 VALUES (2,'w')INSERT INTO test2 VALUES (2,'r')select * from test1 a left join test2 b on a.id=b.id------------------------------------------------------注意结果集有6条数据,test1只有5条/*id name id name1 a 1 q1 b 1 q2 c 2 w2 c 2 r3 d NULL NULL4 e NULL NULL*/