select * from tablea ,table b where tablea.id*=*tableb.id?
create table TABLEA(id int,value1 varchar(50)) insert into tablea select 1,'a' insert into tablea select 2,'b' insert into tablea select 3,'c'create table TABLEB(id int,value2 varchar(50)) insert into TABLEB select 2,'d' insert into TABLEB select 3,'e' insert into TABLEB select 4,'f' select coalesce(a.id,b.id) as id,isnull(a.value1,'') as value1,isnull(b.value2,'') as value2 from tablea a full join tableb b on a.id=b.id
id value1 value2 1 a 2 b d 3 c e 4 f
FULL JOIN 有能用*号连的 ?
select isnull(m.id , n.id) id , isnull(m.value1 , '') value1 , isnull(n.value2 , '') value2 from tablea m full join tableb n on m.id = n.id
create table TABLEA(id int,value1 varchar(50)) insert into tablea select 1,'a' insert into tablea select 2,'b' insert into tablea select 3,'c'create table TABLEB(id int,value2 varchar(50)) insert into TABLEB select 2,'d' insert into TABLEB select 3,'e' insert into TABLEB select 4,'f' select isnull(m.id , n.id) id , isnull(m.value1 , '') value1 , isnull(n.value2 , '') value2 from tablea m full join tableb n on m.id = n.id drop table tablea , tableb/* id value1 value2 ----------- -------------------------------------------------- -------------------------------------------------- 1 a 2 b d 3 c e 4 f(所影响的行数为 4 行) */
insert into tablea select 1,'a'
insert into tablea select 2,'b'
insert into tablea select 3,'c'create table TABLEB(id int,value2 varchar(50))
insert into TABLEB select 2,'d'
insert into TABLEB select 3,'e'
insert into TABLEB select 4,'f'
select coalesce(a.id,b.id) as id,isnull(a.value1,'') as value1,isnull(b.value2,'') as value2
from tablea a full join tableb b on a.id=b.id
1 a
2 b d
3 c e
4 f
?
from tablea m full join tableb n on m.id = n.id
insert into tablea select 1,'a'
insert into tablea select 2,'b'
insert into tablea select 3,'c'create table TABLEB(id int,value2 varchar(50))
insert into TABLEB select 2,'d'
insert into TABLEB select 3,'e'
insert into TABLEB select 4,'f'
select isnull(m.id , n.id) id , isnull(m.value1 , '') value1 , isnull(n.value2 , '') value2
from tablea m full join tableb n on m.id = n.id drop table tablea , tableb/*
id value1 value2
----------- -------------------------------------------------- --------------------------------------------------
1 a
2 b d
3 c e
4 f(所影响的行数为 4 行)
*/
我的意思是这个语句可不可以像左连接不用LEFT JOIN用'*=',右连接用'=*'
这个如果用表达示也用表达式要怎么写呢?
select * from #t1,#t2 where #t1.id*=#t2.id(比方左连接)