select t1.column1,t1.column2,t1.column3,t2.column3 from talbe t1 ,table2 t2 where t1.column1=t2.column1 and t1.column2=t2.column2
用连接就可以了 假设table1中 a b e 的列名 为 a1 b1 e1 假设table2中 a b f 的列名为 a1 b1 f1 代码 select table1.a1 ,table1.b1 ,table1.e1 , table2.f1 from table1 ,table2 where table1.a1=table2.a1 and table1.b1 = table2.b1
f 是不定值的情况 比如当 f为空的时候 table2就变成: a b a c 此时我想得到的结果就变成是: a b e a c e a d e 所以,大家提供的办法对我来说都不可行啊~ 是我没表达清楚,Sorry~ 期待高手来解答~
f 是不定值的情况 比如当 f为空的时候 table2就变成: a b a c 此时我想得到的结果就变成是: a b e a c e a d e 所以,大家提供的办法对我来说都不可行啊~ 是我没表达清楚,Sorry~ 期待高手来解答~
select a.*,c4=isnull(b.c4,'') from table1 a left join table b on a.c1=b.c1 and a.c2=b.c2
from talbe t1 ,table2 t2
where t1.column1=t2.column1 and t1.column2=t2.column2
假设table1中
a b e 的列名 为 a1 b1 e1
假设table2中
a b f 的列名为 a1 b1 f1
代码
select table1.a1 ,table1.b1 ,table1.e1 , table2.f1 from table1 ,table2 where table1.a1=table2.a1 and table1.b1 = table2.b1
比如当 f为空的时候
table2就变成:
a b
a c
此时我想得到的结果就变成是:
a b e
a c e
a d e
所以,大家提供的办法对我来说都不可行啊~
是我没表达清楚,Sorry~
期待高手来解答~
比如当 f为空的时候
table2就变成:
a b
a c
此时我想得到的结果就变成是:
a b e
a c e
a d e
所以,大家提供的办法对我来说都不可行啊~
是我没表达清楚,Sorry~
期待高手来解答~
select a.*,c4=isnull(b.c4,'') from table1 a left join table b
on a.c1=b.c1 and a.c2=b.c2