我有这个
name1 name2 name3 value1 value2 value3
A B C 1 2 3
我真的需要这个
Name Value
A 1
B 2
C 3
请帮帮我。
答案 0 :(得分:1)
您可以使用union
<div class="row checkbox-row">
<div class="col-xs-2 col-xs-offset-4">
<div class="checkbox-inline">
<label class="checkbox-inline">
<input type="checkbox" value="">Adult News</label>
</div>
</div>
<div class="row checkbox-row">
<div class="col-xs-2">
<div class="checkbox-inline">
<label class="checkbox-inline">
<input type="checkbox" value="">Youth News</label>
</div>
</div>
</div>
</div>
答案 1 :(得分:1)
使用以下查询..
Select name1 Name,value1 Value from YourTable
Union all
Select name2 ,value2 from YourTable
Union all
Select name3 ,value3 from YourTable
答案 2 :(得分:0)
临时表方法,如果联合所有执行缓慢或只是为了显示替代....
DECLARE @Table as TABLE (name1 CHAR(1), name2 CHAR(1), name3 CHAR(1), value1 INT, value2 INT, value3 INT)
INSERT INTO @Table VALUES ('A','B','C',1,2,3)
IF OBJECT_ID('tempdb..#TempTable') IS NOT NULL
BEGIN
DROP TABLE #TempTable
END
SELECT name1 as Name, value1 as Value
INTO #TempTable
FROM
@Table
INSERT INTO #TempTable
SELECT name2, value2
FROM
@Table
INSERT INTO #TempTable
SELECT name3, value3
FROM
@Table
SELECT *
FROm
#TempTable