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

【HTML element】How to embed images

The img element allows us to embed images in HTML...

How to optimize MySQL deduplication operation to the extreme

Table of contents 1. Clever use of indexes and va...

How to deploy MySQL and Redis services using Docker

Table of contents How to deploy MySQL service usi...

In-depth analysis of MySQL lock blocking

In daily maintenance, threads are often blocked, ...

How to implement parent-child component communication with Vue

Table of contents 1. Relationship between parent ...

HTML+CSS to create a top navigation bar menu

Navigation bar creation: Technical requirements: ...

MySQL 8.0.19 installation and configuration method graphic tutorial

This article records the installation and configu...

Detailed explanation of the basic commands of Firewalld firewall in Centos7

1. Basics of Linux Firewall The Linux firewall sy...

A brief discussion on several ways to pass parameters in react routing

The first parameter passing method is dynamic rou...

Node quickly builds the backend implementation steps

1. First install node, express, express-generator...

Solution to Nginx session loss problem

In the path of using nginx as a reverse proxy tom...