-
sql生成特殊序列查看全部
-
使用union all连接转换: select user_name,'arms' as equipment, arms from user1 a join user1_equipment b on a.id=user_id union all select user_name,'clothing' as equipment, clothing from user1 a join user1_equipment b on a.id=user_id union all select user_name,'shoe' as equipment, shoe from user1 a join user1_equipment b on a.id=user_id查看全部
-
列转行2 select user_name,'arms' as equipment, arms from user1 a join user1_equipment b on a.id=user_id union all select user_name,'clothing' as equipment, clothing from user1 a join user1_equipment b on a.id=user_id; union all select user_name,'shoe' as equipment, shoe from user1 a join user1_equipment b on a.id=user_id;查看全部
-
使用序列化方法转换: select user_name, replace(substring(substring_index(mobile,','a.id),char_length(substring_index(mobile,',',a.id-1))+1),',','') as mobile --截取字符串 from tb_sequence as a cross join( select user_name, concat(mobile,',') as mobile, --在mobile结尾增加逗号 length(mobile)-length(replace(mobile,',',''))+1 as size --通过mobile总长度-排除逗号后的长度+1计算得出总段数 from user1 as b ) as b on a.id<=b.size查看全部
-
case语句实现列转行 select sum(case when user_name=' 孙悟空' then kills end) as '孙悟空', sum(case when user_name='猪八戒' then kills end) as '猪八戒', sum(case when user_name='沙僧' then kills end) as '沙僧' from user1 a join use_kills b on a.id = b.user_id;查看全部
-
删除重复数据,保留id最大的一条查看全部
-
利用group by having查询重复查看全部
-
生成特殊序列号查看全部
-
生成序列号的方法查看全部
-
使用扩展的序列查看全部
-
使用序列行转列查看全部
-
行转列查看全部
-
行转列 case查看全部
-
行转列 cross join查看全部
-
先需要把mobile列通过分隔字符串转成行 再通过group by having方式删除 再通过group by concat 转换回来 再与原表关联更新查看全部
举报
0/150
提交
取消