SQL Wildcards

SQL wildcards are special characters used in SQL statements to perform pattern matching. These wildcards help to retrieve information that matches a specified pattern in a database.

There are two types of SQL wildcards:

  1. Percentage sign ( % ): The percentage sign represents zero, one or multiple characters. It can be used in the LIKE clause to search for a pattern in a column. For example, the following statement retrieves all the records from the "employees" table where the "name" column starts with "A":
1SELECT * FROM employees 2WHERE name LIKE 'A%';
  1. Underscore ( _ ): The underscore represents a single character. It can also be used in the LIKE clause to search for a pattern in a column. For example, the following statement retrieves all the records from the "employees" table where the "name" column has two characters and the second character is "m":
1SELECT * FROM employees 2WHERE name LIKE '_m';