我查询数据库并获得以下行:
**NAME | DESCRIPTION | MOBILE | EMAIL | CENTER |**
George | Nice guy | 644213568 | geo@gmail.com | NASA |
我想将其转换为:
LABEL | VALUE
Name | George
DESCRIPTION | Nice guy
MOBILE | 644213568
EMAIL | geo@gmail.com
CENTER | NASA
提前谢谢!!!!
答案 0 :(得分:1)
您想要apply
:
select tt.LABEL, tt.VALUE
from table t cross apply
( values ('DESCRIPTION', DESCRIPTION), ('MOBILE', MOBILE), ('EMAIL', EMAIL), ('CENTER', CENTER)
) tt(LABEL, VALUE)
where t.USER_ID = 23;