MySQL巧妙利用help_topic表把以逗号分隔的字符串转换成行

MySQL巧妙利用help_topic表把以逗号分隔的字符串转换成行

脚本:

 
  1.  
    SELECT
      t1.*,
    	SUBSTRING_INDEX(
    		SUBSTRING_INDEX(
    			t1.phy_code,
    			',',
    			t2.help_topic_id + 1
    		),
    		',' ,- 1
    	) AS NEW_PHY_CODE
    FROM
    	so_invoice_t t1
    LEFT JOIN mysql.help_topic t2 ON t2.help_topic_id < (
    	LENGTH(t1.phy_code) - LENGTH(REPLACE(t1.phy_code, ',', '')) + 1
    )

     

你可能感兴趣的:(mybatis)