Home  >  Article  >  Database  >  How to convert value to numeric type in mysql

How to convert value to numeric type in mysql

青灯夜游
青灯夜游Original
2022-03-01 15:15:5314393browse

Conversion method: 1. Use CAST(), the syntax is "SELECT CAST('value' AS SIGNED);"; 2. Use CONVERT(), the syntax is "SELECT CONVERT('value', SIGNED);" ;3. Use the " " operator, the syntax is "SELECT 'value' 0;".

How to convert value to numeric type in mysql

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

Mysql method of converting values ​​​​to numeric types

##Method 1: Use the CAST() function

CAST() function can convert a value (any type) to the specified data type

How to convert value to numeric type in mysql

Example:

SELECT CAST('123' AS SIGNED);

Method 2: Use CONVERT() function

The CONVERT() function converts a value to a specified data type or character set.

Example: How to convert value to numeric type in mysql

SELECT CONVERT('123',SIGNED);

Method 3: Use the " " operator

Example:

SELECT '123'+0;

[Related recommendations :

mysql video tutorial

The above is the detailed content of How to convert value to numeric type 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