How MySQL gets the value after a special character in a variable length string (from StackOverflow)

Source: Internet
Author: User
This is a question from StackOverflow (link http://stackoverflow.com/questions/35122231/ Mysql-how-to-get-numeric-value-after-special-character-in-varchar)
I have a bunch of records, how do I get the right-most value after the slash "/" in this series of records (1,2,10), which is great if you have PHP code that can automatically reset the month value.

Reply:
Suppose you know that all records are in the form of a/x/y, and then "/" is always used as a special symbol, then you can use explode ()
Code:

substring_index(): select substring_index(col,'/',-1)
from t;

If you want to turn what you get t into numbers,
select substring_index(col,'/',-1)+1
from t;

A second answer:
Try this:
$str = "ABC/209116/1";
$replace_with = "0";
$str= substr(0,strrchr($str,"/"));
$replace_with;

'). addclass (' pre-numbering '). Hide (); $ (this). addclass (' has-numbering '). Parent (). append ($numbering); for (i = 1; i <= lines; i++) {$numbering. Append ($ ('

  • '). Text (i)); }; $numbering. FadeIn (1700); }); });

    The above describes how MySQL obtains the value after a special character in a variable length string (from StackOverflow), including the contents of the content, I hope that the PHP tutorial interested in a friend helpful.

  • 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.