行转列 列转行 sql 脚本的编写

行转列 列转行 sql 脚本的编写

1. sql 脚本编写 行转列 列转行

 

表设计

test_table

id varchar(11),

name varchar(255),

table_desc varchar(255)

sql 编写

 

行转列

 

select concatenate("id",""),

concatenate("name",""),

concatenate("desc",""),

concatenate(

""

,(

select *

from test_table a

where 1=1

limit 1

desc

)

)

from test_table b

 

列转行

 

select concatenate("id",""),*

from test_table a

union

(

select b.id

from test_table b

limit 1

desc

)

;

#牛客AI配图神器#

#春招至今,你收到几个面试了?##烂工作和没工作哪个更痛苦?##Agent面试会问什么?##给工作过的公司写一条大众点评,你会怎么写?##面试体验最好和最差的公司#
Java技术 文章被收录于专栏

JavaEE技术 编程开发经验 企业通用技术

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务