Ambika Pravin Sonawane
PRO
last month
Ambikacountry asked

How many wildcards are there in total ? And can you please specify them and mention their use in a sequence to understand properly, like which type of wild cards are used in MS Access and SQL Server.

Abhay Jajodia
Expert
last month
Abhay Jajodia answered

Hi there! Wildcards in SQL make it easier to search for data when you don’t know the exact value.

Different databases use slightly different wildcard symbols, so here’s a quick and easy explanation for SQL Server, MS Access, and SQLite.

In SQL Server:

  • The % symbol matches any number of characters. For example, 'a%' finds values that start with “a”.

  • The _ symbol matches exactly one character, so 'a_' finds two-letter values starting with “a”.

  • You can also use square brackets like [a-f] to match any single character between “a” and “f”.

  • To exclude characters, use [^a-f] or [!a-f], which means anything not in that range.

In MS Access, the wildcards are slightly different:

  • The * symbol works like % and matches any number of characters.

  • The ? symbol represents exactly one character.

  • The # symbol matches a single digit (0–9).

  • You can also use brackets like [abc] to match a, b, or c, and ![abc] to match anything except those letters.

In SQLite, wildcards work the same way as in SQL Server:

  • % matches any number of characters

  • _ matches a single character.

All of these wildcards are used with the LIKE operator to filter results more flexibly depending on your database system.

For more detailed explanations and examples of each wildcard, you can check this link:

https://dbschema.com/blog/tutorials/sql-wildcard-characters/#:~:text=In%20SQL%2C%20a%20wildcard%20character,specified%20pattern%20in%20a%20column.

Hope this helps! Let me know if you’d like more examples or support.

SQL
This question was asked as part of the Learn SQL Basics course.