Separation effect
Separate command lines SELECT substring_index(substring_index('1,2,3,4',',', b.help_topic_id + 1), ',', -1) result FROM mysql.help_topic b where b.help_topic_id < (LENGTH('1,2,3,4') - LENGTH(REPLACE('1,2,3,4', ',', '')) + 1); Command line explanationhelp_topic itself is a Mysql help explanation comment table, which is used to explain various Mysql terms. Since the data ID of this table increases from 0, it is convenient for us to count, but the 8.0.17 version has only 686 data. If it exceeds this number, we need to customize a table It can be used as a temporary table for counting. The query statement will only use help_topic for counting. The excess part is actually dirty data. b.help_topic_id < Get the total number of rows after separation b.help_topic_id < (LENGTH('1,2,3,4') - LENGTH(REPLACE('1,2,3,4', ',', '')) + 1) This statement is actually a traversal, help_topic_id starts from 0 and increases to Intercept in order, first intercept all characters before the nth separator, then intercept the last character of the string
mysql.help_topic no permission solution The function of mysql.help_topic is to connect the data from the SUBSTRING_INDEX function (that is, the data separated by the delimiter) to make a Cartesian product. If you do not have permission to use mysql.help_topic, you can create a temporary table to connect to the table you want to query. Get the maximum number of strings that the field can be split into: SELECT MAX(LENGTH(a.`name`) - LENGTH(REPLACE(a.`name`, ',', '' )) + 1) FROM `test` a; Create a temporary table and add data to it: Notice:
Involved functions substring_index(str, delim, count)
replace(str, from_str, to_str)
length(str) Get the length of a string This is the end of this article about how to split a row of data into multiple rows of data in MySQL based on commas. For more information about how to split a row of data into multiple rows in MySQL based on commas, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Detailed explanation of HTML onfocus gain focus and onblur lose focus events
>>: What is ssh port forwarding? What's the use?
First, let me explain the version of MySQL: mysql...
Docker is an open source engine that makes it eas...
Flex layout is undoubtedly simple and easy to use...
Table of contents 1. We found that this website m...
Table of contents 1. Basic SELECT statement 1. Qu...
Table of contents Overview Hash Properties Host p...
Record the BUG that got me stuck all afternoon to...
Preface This article mainly introduces 4 methods ...
DNS (Domain Name Server) is a server that convert...
Table of contents 1. Background 2. What is silent...
js date time format Convert the date and time to ...
1 Problem description: 1.1 When VMware is install...
Table of contents 1. Introduction to the connecti...
During the front-end development process, a situat...
[LeetCode] 181.Employees Earning More Than Their ...