test

0

Please login or register to vote for this query.

(click on this box to dismiss)

スタック・オーバーフロー

プログラマーとプログラミングに熱心な人々のための質問と回答

declare @table1 as table (id int, col1 varchar(10), col2 varchar(100));
insert into @table1
select 1, 'ABC', 'XYZ' union all
select 2, 'DEF', 'XYZ' union all
select 3, 'GHI', 'XYZ';

declare @table2 as table (id int, col3 varchar(10), col4 varchar(100));
insert into @table2
select 1, 'JKL', '123' union all
select 3, 'MNO', '123' union all
select 5, 'PQR', '123';

select * from @table1;

select * from @table2;

select t1.id, t1.col1, t2.col3, t1.col2 + ' ' + t2.col4 as new_column
from @table1 as t1
join @table2 as t2
on t1.id = t2.id;

Enter Parameters

Options:
Switch to meta site
loading Hold tight while we fetch your results