非常非常难查询

时间:2014-12-02 12:51:08

标签: mysql sql sql-server-2008 tsql union

我有一张表格如下:

**A----B----C----D----F----E**

1----2----3-----4----5----6

1----2----3-----4----5----6

1----2----3-----4----5----6

现在我想查询下表中的表格引导下列A,B列的字段值c,d,列F,E中的值以下列A,B,


决赛桌

**A----B**

1----2

1----2

1----2

3----4

3----4

3----4

5----6

5----6

5----6

2 个答案:

答案 0 :(得分:2)

您想要一个基本的union all查询:

select a, b from table t union all
select c, d from table t union all
select f, e from table t;

答案 1 :(得分:1)

试试这个:

SELECT a AS A, b AS B 
FROM tablea 
UNION ALL
SELECT c AS A, d AS B 
FROM tablea 
UNION ALL
SELECT f AS A, e AS B 
FROM tablea;