22,294
社区成员
发帖
与我相关
我的任务
分享create table A(name int , category int)
insert into A values(1, 1 )
insert into A values(2, 1 )
insert into A values(3, 1 )
insert into A values(4, 2 )
insert into A values(5, 2 )
create table B(fen int , name int , rq int)
insert into B values(100, 1 , 2007)
insert into B values(100, 2 , 2003)
go
select a.* , b.fen , b.rq from a left join b on a.name = b.name where a.category = 1
drop table A,B
/*
name category fen rq
----------- ----------- ----------- -----------
1 1 100 2007
2 1 100 2003
3 1 NULL NULL
(所影响的行数为 3 行)
*/
create table A(name int , category int)
insert into A values(1, 1 )
insert into A values(2, 1 )
insert into A values(3, 1 )
insert into A values(4, 2 )
insert into A values(5, 2 )
create table B(fen int , name int , rq int)
insert into B values(100, 1 , 2007)
go
select a.* , b.fen , b.rq from a left join b on a.name = b.name where a.category = 1
drop table A,B
/*
name category fen rq
----------- ----------- ----------- -----------
1 1 100 2007
2 1 NULL NULL
3 1 NULL NULL
(所影响的行数为 3 行)
*/