Home   |   About   |   Terms   |   Contact    
Read & Learn
 

List of wildcard used in MySQL

Web Design & Development

☯ All Web Related Articles     ☯ All Articles


A new product.






Popular Google Pages:




This article is regarding list of wildcard used in MySQL.
Last updated on: .



◕ A wildcard is used to match any other character or characters within a string.


List of wildcards



◕ List of wildcards for LIKE operator in MySQL

%
_ (underscore)



◕ List of wildcards for REGEXP operator in MySQL

^

$

.

[ ]

^[ ]

^[ ]$

[^ ]

All examples are given bellow with codes.

Use of wildcards with examples and codes

Let, our database has a table with a column.
Table name: sky
Column name: birds




◕ Wildcard: %
Description: It matches any number of characters.
Example:

$wing = mysql_query("SELECT birds FROM sky WHERE birds
LIKE ' %al ' " );

It matches any number of characters before al.



◕ Wildcard: %
Description: It matches any number of characters.
Example:

$wing = mysql_query("SELECT birds FROM sky WHERE birds
LIKE ' al% ' " );

It matches any number of characters after al.



◕ Wildcard: %
Description: It matches any number of characters.
Example:

$wing = mysql_query("SELECT birds FROM sky WHERE birds
LIKE ' %al% ' " );

It matches any number of characters before and after al.



◕ Wildcard: _
Description: It matches with any single character.
Example:

$wing = mysql_query("SELECT birds FROM sky WHERE birds
LIKE ' _agal ' " );

It will match with single character before agal.



◕ Wildcard: _
Description: It matches with any single character.
Example:

$wing = mysql_query("SELECT birds FROM sky WHERE birds
LIKE ' _a_al ' " );

It will match with single character in its places. It can match with a word eagal or pagal.



◕ Wildcard: ^
Example:

$wing = mysql_query("SELECT birds FROM sky WHERE birds
REGEXP ' ^e ' " );

It will match with any string which starts with e.



◕ Wildcard: $
Example:

$wing = mysql_query("SELECT birds FROM sky WHERE birds
REGEXP ' al$ ' " );

It will match with any string which ends with al



◕ Wildcard: [ ]
Example:

$wing = mysql_query("SELECT birds FROM sky WHERE birds
REGEXP ' [al] ' " );

It will match with any string which contains the letter a or l.



◕ Wildcard: [a-z]
Example:

$wing = mysql_query("SELECT birds FROM sky WHERE birds
REGEXP ' [a-z] ' " );

It will match with any string which contains the letter from a to z.

We can also write
[A-Z] : To match any character between A to Z.

[0-9] : To match any character between 0 to 9.

[a-zA-Z0-9] : To match any character between a to z, A to Z and 0-9.



◕ Wildcard: ^[ ]
Example:

$wing = mysql_query("SELECT birds FROM sky WHERE birds
REGEXP ' ^[al] ' " );

It will match with any string which starts with al.



◕ Wildcard: ^[ ]$
Example:

$wing = mysql_query("SELECT birds FROM sky WHERE birds
REGEXP ' ^[al]$ ' " );

It will match with and only with the word al.



◕ Wildcard: [^ ]
Example:

$wing = mysql_query("SELECT birds FROM sky WHERE birds
REGEXP ' [^al] ' " );

It will match with any string which has no a or l in it.



◕ All the best!



◕ Related articles:
► Eliminate render blocking CSS
► Eliminate Render Blolcking JavaScript or jQuery
► How google will trust a site?
► What is browser cache? How to leverage browser caching of your website? Browser Caching with .htaccess
► URL Redirection with .htaccess
► Ask Google to re-crawl your URL.
► Display HTML codes in WebPage.
► Image Optimization
► Use HTML & CSS for Responsive Image.
► Notepad Application.





Popular Google Pages:





Top of the page

Amazon & Flipkart Special Products

   


Top of the page