表名:uss
列名:a,b,c,d
select * from uss的数据:
a b c d
-----------
1 1 2 3
如何实现查询让一行数据以一列的形式输出呢?输出结果如下:
column1
1
1
2
3
注:不能用临时,这种方法我已实现。感觉这种方法太苯了,跪求哪位高手能不能给出更好的实现方法。
不好意思,小学没毕业,少打了一字。
注:不能用临时表,这种方法我已实现。感觉这种方法太苯了,跪求哪位高手能不能给出更好的实现方法
SQL:如何把一行的数据以一列的形式输出
答案:2 悬赏:80
解决时间 2021-04-08 05:13
- 提问者网友:心裂
- 2021-04-07 06:04
最佳答案
- 二级知识专家网友:疯山鬼
- 2021-04-07 06:47
select a column1 from uss
union
select b column1 from uss
union
select c column1 from uss
union
select d column1 from uss
union
select b column1 from uss
union
select c column1 from uss
union
select d column1 from uss
全部回答
- 1楼网友:桃花别处起长歌
- 2021-04-07 07:18
declare @combinedstring varchar(max)
select @combinedstring = coalesce(@combinedstring + ', ', '') + data
from tablename
where id = 1
select @combinedstring
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯