请问您见过最惊艳的sql查询语句是什么?

6个月前 (11-15) 0 点赞 0 收藏 0 评论 15 已阅读

用户科室数据,一条用户记录的字段中放着用分隔符分割的多个权限科室,需要拆成行记录,这个SQL让我自己写,至今还是写不出来。

原数据
转成这样的
SELECTa.`user_id`,substring_index( substring_index( a.`depts`, '/', b.`pk` + 1 ), '/',- 1 ) AS dept_id FROM( SELECT `depts`, `id` AS user_id FROM `用户医护人员` ) AS aJOIN `s_split_index` AS b ON b.`pk` < ( char_length( a.`depts` ) - char_length( REPLACE ( a.`depts`, '/', '' ) ) + 1 )

用到的s_split_index表长这样:

请问您见过最惊艳的sql查询语句是什么?

本文收录在
0评论

登录

忘记密码 ?

切换登录

注册