mysql把一字段拆分為多行


sql語句

select a.house_no as '房子',substring_index(substring_index(a.name,',',b.help_topic_id+1),',',-1) as '擁有者' 
from  aa a
join   mysql.help_topic b on b.help_topic_id < (length(a.name) - length(replace(a.name,',',''))+1);

 

關鍵點
mysql.help_topic b on b.help_topic_id < (length(a.name) - length(replace(a.name,',',''))+1)

name格式:張三,李四,王五


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM