我的表是:
我的table1是:
col1 col2
Con TB
Con TC
Arr A
Arr B
我想要这个结果:
column1
TB#A
TB#B
TC#A
TC#B
请写下查询!!!
罐
答案 0 :(得分:1)
请尝试:
select
a.col2+'#'+b.col2
from
T1 a, T1 b
where a.col1='Con'and
b.col1='Arr'
OR
select
a.col2+'#'+b.col2
from
T1 a CROSS JOIN T1 b
where a.col1='Con'and
b.col1='Arr'
答案 1 :(得分:0)
select T1.col2 + '#' + T2.col2
from Table1 as T1
cross join Table1 as T2
where T1.col1 = 'Con' and T2.col1 = 'Arr'
<强> sql fiddle demo 强>
答案 2 :(得分:-1)
UPDATE Table1
SET col1 = col + '#' + Col2
或您可以在结果中添加新列而不更改数据库中的数据
像这样的东西
SELECT CAST(Col1 AS NVARCHAR) + '#' + CAST(Col2 AS NVARCHAR) AS NewColumn
FROM Table1