-
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
提交
取消