SQL语句问题,easy(10分)

  • 主题发起人 主题发起人 suninrain
  • 开始时间 开始时间
S

suninrain

Unregistered / Unconfirmed
GUEST, unregistred user!
有表:
id field1 field2 field3
1 a b c
2 d e f
..........

现需要select ..........from table where id=1得到下面的结果
1 a
1 b
1 c
不知道如何做啊
 
select id,field1 as a from table where id=1
union
select id,field2 as a from table where id=1
union
select id,field3 as a from table where id=1
 
这样写:
select id,field1 as field from table where id=1
union all
select id,field2 as field from table where id=1
union all
select id,field3 as field from table where id=1;
 
多人接受答案了。
 
后退
顶部