Home  >  Article  >  Database  >  How to convert string to number in mysql

How to convert string to number in mysql

青灯夜游
青灯夜游Original
2021-12-27 18:45:1771412browse

Mysql method to convert a string into a number: 1. Use the " " operator, the syntax "'string' 0"; 2. Use the cast() function, the syntax "cast('string' as Numerical type)"; 3. Use the convert() function, the syntax is "convert('string', numerical type)".

How to convert string to number in mysql

The operating environment of this tutorial: windows7 system, mysql8 version, Dell G3 computer.

mysql Three ways to convert string to number

Method 1: 0

Method 2: cast('string' as numerical type)

Numeric types can be divided into three types:

Integers: SIGNED

Unsigned integer: UNSIGNED

Floating point number: DECIMAL

Method 3: convert('string', numeric type)

Numeric types can also be divided into three types:

Integer: SIGNED

Unsigned integer: UNSIGNED

## Floating point number: DECIMAL

【Related recommendations:

mysql video tutorial

The above is the detailed content of How to convert string to number in mysql. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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