The best SQL wildcard Tutorial In 2024, In this tutorial you can learn SQL wildcard,The demo database,Use SQL% wildcard,Examples,Examples,Use SQL _ wildcards,Examples,Examples,Using SQL [charlist] wildcard,Examples,Examples,Examples,
Wildcards can be used in place of any other character string.
In SQL, SQL LIKE operator with the wildcard character used together.
SQL wildcard search for data in the table.
In SQL, you can use the following wildcards:
通配符 | 描述 |
---|---|
% | 替代 0 个或多个字符 |
_ | 替代一个字符 |
[ charlist ] | 字符列中的任何单一字符 |
[^ charlist ] 或 [! charlist ] |
不在字符列中的任何单一字符 |
In this tutorial, we will use w3big sample database.
The following is a selected "Websites" table data:
+----+--------------+---------------------------+-------+---------+ | id | name | url | alexa | country | +----+--------------+---------------------------+-------+---------+ | 1 | Google | https://www.google.cm/ | 1 | USA | | 2 | 淘宝 | https://www.taobao.com/ | 13 | CN | | 3 | 本教程 | http://www.w3write.com/ | 4689 | CN | | 4 | 微博 | http://weibo.com/ | 20 | CN | | 5 | Facebook | https://www.facebook.com/ | 3 | USA | | 7 | stackoverflow | http://stackoverflow.com/ | 0 | IND | +----+---------------+---------------------------+-------+---------+
The following SQL statement selects all site url letters "https" begins:
Execution output:
The following SQL statements contained mode select url "oo" of all sites:
Execution output:
The following SQL statement to select a name to start any character, then "oogle" all customers:
Execution output:
The following SQL statement select name to "G" Start, then any character, then "o", then any character, then "le" for all Web sites:
Execution output:
MySQL use REGEXP or NOT REGEXP operators (or RLIKE and NOT RLIKE) to operate regular expressions.
The following SQL statement select name all sites to "G", "F" or "s" begins:
Execution output:
The following SQL statement select name beginning with A to H letters website:
Execution output:
The following SQL statement to select the name does not begin with the letters A to H website:
Execution output: