MySQL How to get the value after special characters in a variable-length string (from stackoverflow)

WBOY
Release: 2016-07-29 09:04:31
Original
1182 people have browsed it

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 string of records, how can I get the rightmost value (1, 2, 10) after the slash "/" in this string of records. It would be great if you have PHP code that can automatically reset the month value.
MySQL 如何在可变长字符串中获得在特殊字符之后的数值(来自stackoverflow)

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

substring_index(): select substring_index(col,'/',-1) <br> from t;
If you want to turn the obtained t into a number
select substring_index(col,'/',-1)+1 <br> from t;

Second answer:
Try this:
$str = "ABC/209116/1"; <br> $replace_with = "0"; <br> $str= substr(0,strrchr($str,"/")); <br> $replace_with;

').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

The above introduces how MySQL obtains the value after the special character in a variable-length string (from stackoverflow), including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template