admin 管理员组文章数量: 887021
2024年1月18日发(作者:php循环输出json)
mysql分割数组_MySQL通过SUBSTRING_INDEX函数拆分字符串为数组单元vim #Define variablesMYSQL_HOME=/usrSQL_SCRIPT_DB_CONNECTION_STRING='-uroot -p'root''SQL_SCRIPT_PARAMETERS_LIST="'PARAM1 PARAM2 PARAM3'"#Execute the command#CMD_SQL_SCRIPT_EXECUTION=${MYSQL_HOME}/bin/mysql ${SQL_SCRIPT_DB_CONNECTION_STRING} -e "set
@VAR1=$SQL_SCRIPT_PARAMETERS_LIST ; source ${SQL_SCRIPT_FILE_LOCATION}/${SQL_SCRIPT_NAME}.sql ;" >>${myLogFile}${MYSQL_HOME}/bin/mysql ${SQL_SCRIPT_DB_CONNECTION_STRING} -e "set
@VAR=$SQL_SCRIPT_PARAMETERS_LIST;set @VAR_NUM=length(@VAR)-length(REPLACE(@VAR,' ',''))+1; /* define the total number of the variables */set @VAR_POS=0; /* define the variable position in the string *//* define the variables' value, if the the variable doesn't exist, its value is null */set @VAR_1 = if(@VAR_POS < @VAR_NUM,SUBSTRING_INDEX(SUBSTRING_INDEX(@VAR, ' ',@VAR_POS:=@VAR_POS+1),' ',-1),null);set @VAR_2 = if(@VAR_POS < @VAR_NUM,SUBSTRING_INDEX(SUBSTRING_INDEX(@VAR, ' ',@VAR_POS:=@VAR_POS+1),' ',-1),null);set @VAR_3 = if(@VAR_POS < @VAR_NUM,SUBSTRING_INDEX(SUBSTRING_INDEX(@VAR, ' ',@VAR_POS:=@VAR_POS+1),' ',-1),null);set @VAR_4 = if(@VAR_POS < @VAR_NUM,SUBSTRING_INDEX(SUBSTRING_INDEX(@VAR, ' ',@VAR_POS:=@VAR_POS+1),' ',-1),null);set @VAR_5 = if(@VAR_POS < @VAR_NUM,SUBSTRING_INDEX(SUBSTRING_INDEX(@VAR, ' ',@VAR_POS:=@VAR_POS+1),' ',-1),null);set @VAR_6 = if(@VAR_POS < @VAR_NUM,SUBSTRING_INDEX(SUBSTRING_INDEX(@VAR, ' ',@VAR_POS:=@VAR_POS+1),' ',-1),null);set @VAR_7 = if(@VAR_POS < @VAR_NUM,SUBSTRING_INDEX(SUBSTRING_INDEX(@VAR, ' ',@VAR_POS:=@VAR_POS+1),' ',-1),null);select @VAR_1, @VAR_2, @VAR_3, @VAR_4, @VAR_5, @VAR_6, @VAR_7;"sh ing: Using a password on the command line interface can be insecure.+--------+--------+--------+--------+--------+--------+--------+| @VAR_1 | @VAR_2 | @VAR_3 | @VAR_4 | @VAR_5 | @VAR_6 | @VAR_7 |+--------+--------+--------+--------+--------+--------+--------+| PARAM1 | PARAM2 | PARAM3 | NULL | NULL | NULL | NULL |
+--------+--------+--------+--------+--------+--------+--------+
版权声明:本文标题:mysql分割数组_MySQL通过SUBSTRING_INDEX函数拆分字符串为数组单元 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.freenas.com.cn/jishu/1705587038h491226.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论