To undertake the above: MySQL in the premise of not writing stored procedures or functions, the use of SQL statements to split a string into an array
The main idea is actually the same: enough to build a sequence, and then combine the features of MySQL's Substring_index function to split the string.
SET @str ="A,b,c,d,e,f,g,h,i,j,k";SET @delim="," ;SET @str_length=Length@str)-LengthREPLACE(@str,@delim,"') )+1 ;SELECTSubstring_index (Substring_index (@str,@delim, Tmp.seq),@delim,- 1) asStr_split from( SELECTs1.i+s2.i+s3.i+S4.i+S5.i+S6.i+S7.i+S8.i+S9.i+1 asseq from(SELECT 0 asIUNION All SELECT 1 asi) S1 Cross JOIN(SELECT 0 asIUNION All SELECT 2 asi) S2 Cross JOIN(SELECT 0 asIUNION All SELECT 4 asi) S3 Cross JOIN(SELECT 0 asIUNION All SELECT 8 asi) S4 Cross JOIN(SELECT 0 asIUNION All SELECT - asi) S5 Cross JOIN(SELECT 0 asIUNION All SELECT + asi) S6 Cross JOIN(SELECT 0 asIUNION All SELECT - asi) S7 Cross JOIN(SELECT 0 asIUNION All SELECT - asi) S8 Cross JOIN(SELECT 0 asIUNION All SELECT the asi) S9ORDER bySeqlimit -) TMPWHERETmp.seq<= @str_length
MySQL directly splits strings into arrays with SQL