mysql將一行變成多行的方法:1、將一行變成多行,代碼為【substring_index(substring_index( a.rn,’,’,b.help_topic_id + 1 ? ?),’,’ ,- 1)】;2、將多列變成多行。
mysql將一行變成多行的方法:
把? ? ?
轉(zhuǎn)成
SELECT ????substring_index(substring_index(?a.rn,',',b.help_topic_id?+?1????),','?,-?1)?AS?rn FROM ????(select?'1,2,3,4'?as?rn)?a?? JOIN?mysql.help_topic?b?ON?b.help_topic_id?<p>圖A轉(zhuǎn)成圖B</p><p><img src="https://img.php.cn/upload/image/396/912/677/1601262104361576.png" title="1601262104361576.png" alt="19275fe886e86f672f00b79d7057937.png"></p><p>圖a</p><p><img src="https://img.php.cn/upload/image/500/405/941/1601262109215136.png" title="1601262109215136.png" alt="6f3e1d38d92ed1e69418732db8a3097.png"></p><p>圖b</p><pre class="brush:php;toolbar:false">SELECT ????substring_index(substring_index(?a.rn,',',b.help_topic_id?+?1????),??','?,-?1????)?AS?rn FROM ????(select?SUBSTR(GROUP_CONCAT(?REPEAT(CONCAT(number,','),fre)?SEPARATOR?''),1,LENGTH(GROUP_CONCAT(?REPEAT(CONCAT(number,','),fre)?SEPARATOR?''))-1)?as?rn??from?numbers?)?a?? JOIN?mysql.help_topic?b?ON?b.help_topic_id?<blockquote><p><strong>更多相關(guān)免費(fèi)學(xué)習(xí)推薦:</strong><a href="https://www.php.cn/course/list/51.html" target="_blank"><strong>mysql教程</strong></a><strong>(視頻)</strong></p></blockquote>
? 版權(quán)聲明
文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載。
THE END