What is the method of converting MySQL strings to numbers
This article mainly explains "what is the method of converting MySQL strings into numbers". The content of the explanation in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what is the method of converting MySQL strings into numbers".
Method 1: add 0 directly
Select '123' + 0
Method 2: function convert
Syntax: convert (value, type)
Type can be:
Decimal floating point signed integers unsigned unsigned integers
Select convert ('123 signed)
Method 3: function cast
Syntax: cast (value as type)
Type can be:
Decimal floating point signed integers unsigned unsigned integers
Select cast ('123' as signed)
Add: let's take a look at the three ways of converting mysql strings to numbers.
Method 1: + 0
Method 2: cast ('string' as numeric type)
Numeric types can be divided into three types:
Integer: SIGNED
Unsigned integers: UNSIGNED
Floating point numbers: DECIMAL
Method 3: convert ('string', numeric type)
Numeric types can also be divided into three types:
Integer: SIGNED
Unsigned integers: UNSIGNED
Floating point numbers: DECIMAL
Thank you for reading, the above is the content of "what is the method of converting MySQL strings into numbers". After the study of this article, I believe you have a deeper understanding of what the method of converting MySQL strings into numbers is, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!