MySQL query specifies that the field is not a number and comma sql

MySQL query specifies that the field is not a number and comma sql

Core SQL statements

MySQL query statement that does not contain numbers:

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

MySQL query statement for pure numbers:

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

Related article ids are all numbers or commas. So the following MySQL query does not contain numbers and commas:

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

MySQL query a column that is not a number

Columns containing numbers:

SELECT column name FROM table name WHERE column name REGEXP '[0-9]{1,}'

Columns that do not contain numbers:

SELECT column name FROM table name WHERE column name REGEXP '[0-9]{1,}' = 0

mysql regular expression query non-digit

I want to query the regular expression sql for the field age content that is not a number

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

or

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

Multiple numbers

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

Introduction to regexp operators in MySQL

The regexp operator is used to perform more complex string comparison operations. (Can only operate on strings)

Special characters belonging to regexp operators

^ Matches the beginning of a string. For example, '^董' means a string starting with 董.
$ matches the end of a string.
. matches any single character including carriage return and newline.
* matches any sequence of 0 or more characters preceding the asterisk. (The asterisk is optional)
+ matches any sequence of one or more characters preceding the plus sign. (Must be preceded by a plus sign)
? Matches 0 or more characters before the question mark.
{n} matches the sequence of the content before the brackets n times.
() matches the contents of the brackets.
[abc] matches the string abc that appears in the square brackets.
[az] matches one character between the characters in the square brackets.
[^az] matches a character that is not between az in the square brackets. `

For more information, please refer to this article: https://www.jb51.net/article/72928.htm

You may also be interested in:
  • mysql regular expression query contains non-digits and characters records
  • Example analysis of the search function of MySQL regular expressions (regexp and rlike)
  • Commonplace talk about the usage of MYSQL pattern matching REGEXP and like
  • Analysis of the usage of replace and regexp for regular expression replacement in MySQL
  • Detailed introduction to the use of MySQL fuzzy query LIKE and REGEXP
  • Complete guide to using REGEXP regular expressions in MySQL
  • Summary of MySQL fuzzy query like and regexp
  • Usage of replace and regexp in mysql database

<<:  Detailed tutorial on deploying Django project using Docker on centos8

>>:  JavaScript implements circular progress bar effect

Recommend

How to use the jquery editor plugin tinyMCE

Modify the simplified file size and download the ...

Docker exec executes multiple commands

The docker exec command can execute commands in a...

Solve the problem of secure_file_priv null

Add secure_file_priv = ' '; then run cmd ...

Solution to MySQL server login error ERROR 1820 (HY000)

Fault site: Log in to the MySQL server and get th...

CSS3 uses animation attributes to achieve cool effects (recommended)

animation-name animation name, can have multiple ...

Solve the problem of inconsistent MySQL storage time

After obtaining the system time using Java and st...

Detailed explanation of the use of Join in Mysql

In the previous chapters, we have learned how to ...

Docker image import and export code examples

Import and export of Docker images This article i...

How to backup MySQL regularly and upload it to Qiniu

In most application scenarios, we need to back up...

Solve the problem of blank gap at the bottom of Img picture

When working on a recent project, I found that th...

Mysql classic high-level/command line operation (quick) (recommended)

Since I need to learn how to build servers and da...

Text mode in IE! Introduction to the role of DOCTYPE

After solving the form auto-fill problem discussed...