Mysql method of splitting a string into multiple lines: You can use the SUBSTRING_INDEX() function to split, such as [substring_index(substring_index(a.chain,'_',b.topic_id 1)].
You can use the string interception function SUBSTRING_INDEX to achieve this.
(Recommended tutorial: mysql video tutorial)
Syntax:
SUBSTRING_INDEX(str, delimiter, count)
Description:
Returns a substring of str, intercepted at the position where delimiter appears count times. If count > 0, count from the left, and Return the substring before the position; if count
delimiter is case-sensitive and multi-byte safe.
Example:
SELECT substring_index(substring_index(a.chain,'_',b.help_topic_id + 1),'_' ,- 1)AS ID FROM (select '1_11_1223_1242' as chain) a JOIN mysql.help_topic b ON b.help_topic_id < (length(a.chain) - length( replace(a.chain, '_', '') ) + 1)
Execution result:
The above is the detailed content of How to split a string into multiple lines in mysql. For more information, please follow other related articles on the PHP Chinese website!