SQL wildcards

SQL wildcards can substitute for one or more characters when searching for data in a database.

It  uses with the SQL LIKE operator

MySQL Table – users

+—-+——+
| id | name |
+—-+——+
|  1 | PHP  |
|  2 | JS   |
|  3 | HTML |
|  5 | ASP  |
+—-+——+

Example

mysql> select * from users WHERE name LIKE ‘%HP’;
+—-+——+
| id | name |
+—-+——+
|  1 | PHP  |
+—-+——+
1 row in set (0.00 sec)

Here % is the wildcard

Other wildcard available

‘ – ‘ – substitute for a single character
[char-list] – substitute for given characters