『壹』 sql兩列合並
試試看!
select cast(sid as varchar(max))+':'+cast(AllotSID as varchar(max)) as bane from PAS_AllotRatio
『貳』 sql 兩列合並成一列的問題
-- a b 類型為varchar
declare @t1 table(a varchar(10),b varchar(10))
insert into @t1
select '1','1' union
select '2','2' union
select '3','3'
select a+b c from @t1
--a b類型為int
declare @t2 table(a int,b int)
insert into @t2
select 1,1 union
select 2,2 union
select 3,3
select cast(a as varchar)+cast(b as varchar) c from @t2
--結果如下:
(3 個資料列受到影響)
c
--------------------
11
22
33
(3 個資料列受到影響)
(3 個資料列受到影響)
c
------------------------------------------------------------
11
22
33
(3 個資料列受到影響)
『叄』 SQL 將兩列的數據合並在一列
selectxxaszzfrom表unionallselectyyfrom表;
『肆』 sql,把兩個表中的兩列數據合到一個表中
兩個表的數據量一樣的嗎?
合並後創建新表嗎?
需要藉助輔助列
select
identity(int,1,1)
as
guid
,val
into
#1
from
table1
select
identity(int,1,1)
as
guid
,val
into
#2
from
table2
select
a.val
as
val1,b.val
as
val2
into
table3
from
#1
a
inner
join
#2
b
on
a.guid
=
b.guid
『伍』 SQL 兩列合並的問題
改為
select isnull(convert(varchar(30),A.a,120),'')+isnull(convert(varchar(30),B.b,120)AS time,'')
『陸』 SQL怎樣合並表中兩列的值為一列來顯示
select concat(name,id) as nameid,age
from example
具體可以參考:網頁鏈接