Is there a explode function solution in mysql like PHP?

Source: Internet
Author: User
Tags strcmp
Is there a explode function in mysql like PHP?
Ask

------Solution--------------------
I'll give you an example of a stored procedure I've written that you want.
DELIMITER $$

DROP PROCEDURE IF EXISTS ' sp_get_new_release ' $$

CREATE definer= ' root ' @ ' localhost ' PROCEDURE ' sp_get_new_release ' (in var_str varchar (20),
In Var_note_language char (5))
BEGIN
DECLARE CNT int;
DECLARE I int;
SET @curs = var_str;
SET @op = "'";
SET @cur_lang = ' en ';
SET @full_version = ';
SET @sql = ' SELECT ' from software_release a WHERE 1 = 1 ';
SELECT COUNT (*) from Software_release WHERE STRCMP (note_language,var_note_language) = 0 to CNT;
IF cnt! = 0 Then
SET @sql = CONCAT (@sql, ' and STRCMP (A.note_language, ', @op, Var_note_language, @op, ') = 0 ');
ELSE
SET @sql = CONCAT (@sql, ' and STRCMP (A.note_language, ', @op, @cur_lang, @op, ') = 0 ');
END IF;
Loop1:loop
SET i = LOCATE ('. ', @curs, 1);
SET @a = Left (@curs, i-1);
SET @full_version = CONCAT (@full_version, REPEAT (' 0 ', (4-length (@a))), @a);
SET @curs = SUBSTR (@curs, i+1);
IF INSTR (@curs, '. ') = 0 Then
SET @a = @curs;
SET @full_version = CONCAT (@full_version, REPEAT (' 0 ', (4-length (@a))), @a);
LEAVE Loop1;
END IF;
END LOOP Loop1;
SET @sql = CONCAT (@sql, ' and full_version > = ', @op, @full_version, @op);
PREPARE S1 from @sql;
EXECUTE S1;
deallocate PREPARE S1;
end$$

DELIMITER;
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.