mysql行转列

select left(substring('p1111',help_topic_id+1),1) as num from mysql.help_topic where help_topic_id < length('p1111')


select substring_index(substring_index(mmm.bdbh,',',help_topic_id+1),',',-1) , substring_index(substring_index(mmm.bdmc,',',help_topic_id+1),',',-1) from 
(select bdbh,bdmc from tb_bid_pwh where id="3ce35693ed8dcde5f5558628ef1946a0") as mmm,mysql.help_topic where help_topic_id < length(mmm.bdbh)-length(REPLACE(mmm.bdbh,',',''))+1


SELECT substring_index(substring_index(p.bdbh,',',h.help_topic_id+1),',',-1) as bdbh, substring_index(substring_index(p.bdmc,',',h.help_topic_id+1),',',-1) as bdmc
from tb_bid_pwh p,mysql.help_topic h
where p.id='3ce35693ed8dcde5f5558628ef1946a0' and h.help_topic_id <length(p.bdbh)-length(REPLACE(p.bdbh,',',''))+1 ORDER BY bdbh

 

posted @ 2022-05-24 13:57  紫花地丁year  阅读(62)  评论(0编辑  收藏  举报