Use of MySQL Like statements

  • 2020-06-03 08:34:28
  • OfStack

Example 1. Query fields contain data that is not in English

FROM `m_user`
WHERE `emp_no`
REGEXP '[^ -~]' =1

Column 2. This will work out everything that is not in English

FROM table
WHERE name
NOT REGEXP '[a-zA-Z0-9]+'

Of course, in addition to regexp, you can also use FIND_IN_SET,like
Note how FIND_IN_SET() is used in mysql, and how FIND_IN_SET() is used, and how F world 2 collates the use of IND_IN_SET() differs from in().
Query table field pingid = (1,2,3,) in mysql
SELECT * FROM `linkinfo` WHERE `pingid` REGEXP '{id},' AND `pingid` NOT REGEXP '[[:alnum:]]+{id},'  

Using the above statement, you can find out

In MySQL, SQL's schema is case-insensitive by default. Some examples are shown below. Note that when you use SQL mode, you cannot use = or! =; Instead, use the LIKE or NOT LIKE comparison operator.
SELECT field FROM Table WHERE Field Like condition
In terms of conditions, SQL provides four matching patterns:
1, % : Represents any one or more characters. Characters of any type and length can be matched.
Such as

 The following code   Copy the code  
SELECT * FROM  [ user ]  WHERE u_name LIKE  ' %3%' 

Related articles: