Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does mysql determine whether it is a numeric type?

2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "how mysql judges whether it is a digital type." Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let Xiaobian take you to learn "mysql how to judge whether it is a digital type"!

In mysql, you can use the REGEXP operator to determine whether data is of numeric type, using the syntax "String REGEXP '[^0-9.] '"; This operator is an abbreviation for a regular expression that returns true if the data character contains a number, and false otherwise.

Operating environment of this tutorial: Windows 10 system, mysql version 8.0.22, Dell G3 computer.

How does mysql determine whether it is a numerical type

REGEXP operator with mysql

REGEXP operator, short for regular expression, which is very powerful for searching strings, here's how it works

{String} REGEXP '[^0-9.] '

The first string is what we want to judge, and the last string is a regular expression of mysql, which means matching characters that are not numbers or decimal points.

Returns true if the String contains a number other than 0-9 or a decimal point, false otherwise.

usage

select ('123a' REGEXP '[^0-9.] ');

--'123a' contains character 'a' output 1 mysql constant true output 1 false output 0

select * from tablename where (name REGEXP '[^0-9.] ') = 1

Query records whose name is all numbers

Note: If there are spaces in the string, it will also match the regular expression and return 1. If you want to remove the spaces at both ends, you have to use the trim() function on the string.

#Query speed column for data that is not a number

select * from standard_csbi_service_tree_1d_full where ('2134' REGEXP '[^0-9.] ')=1;

#Query speed column is numeric data

select * from standard_csbi_service_tree_1d_full where (speed REGEXP '[^0-9.] ')=0; At this point, I believe that everyone has a deeper understanding of "how mysql judges whether it is a digital type", so let's actually operate it! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report