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

MySQL query sql with specified fields that are not numbers and commas

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

Share

Shulou(Shulou.com)06/01 Report--

Core sql statement

MySQL queries statements that do not contain numbers:

SELECT * FROM test WHERE `name` regexp '[^0-9]';

MySQL queries pure numeric statements:

SELECT * FROM test WHERE `name` regexp '[0-9]';

Related articles id, are numbers or commas, then the following statements MySQL query does not contain numbers and commas:

SELECT * FROM test WHERE `name` regexp '[^0-9,]';

MySQL queries a column that is not a number

Columns containing numbers:

SELECT Column Name FROM Table Name WHERE Column Name REGEXP '[0-9]{1,}'

Columns without numbers:

SELECT Column Name FROM Table Name WHERE Column Name REGEXP '[0-9]{1,}' = 0

mysql regular expression query non-numeric

Want to query regular expression sql whose field age content is not numeric

SELECT `age` FROM `table_name` WHERE `age` REGEXP '^[^0-9]$';

or

SELECT `age` FROM `table_name` WHERE `age` NOT REGEXP '^[0-9]$';

more digital

select * from table_name where `age` REGEXP '[^0-9]{1,}'

Introduction to regexp operator in MySQL

The regexp operator is used to perform more complex string comparisons. (Only strings can be manipulated)

Special characters belonging to regexp operator

^Matches the beginning of a string. For example,'^Dong' is a string starting with Dong.

$matches the end of the string.

. Matches any single character including carriage returns and new lines.

* Matches any sequence of 0 or more characters preceding an asterisk. (There may not be one before the asterisk)

+ Matches any sequence of one or more characters preceding the plus sign. (Must be before plus)

?Matches 0 or more characters before the question mark.

{n}A sequence that matches n occurrences of the content preceding the parenthesis.

() matches the contents of the parenthesis.

[abc]Matches the string abc that appears in square brackets.

[a-z]Matches 1 character between a-z in square brackets.

[^a-z] matches 1 character in square brackets that is not between a-z.`

For more information, see this article: www.jb51.net/article/72928.htm

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