Showing posts with label wildcard. Show all posts
Showing posts with label wildcard. Show all posts

Wednesday, 4 April 2012

SQL: wildcards

   


While we all know about the "%" wildcard, we might not know that there are other interesting ways of using special characters when building queries.
I suppose you are aware of what a wildcard is. Anyway, if you're new to SQL, wildcards are special characters used in queries and they can be used to substitute one or more characters while retrieving data from a database.
We must remember that we can use wildcards only with the "LIKE" operator.

Before going into the available wildcards, let me show you a basic example:
SELECT productCode, description, price
FROM prodTable
WHERE description LIKE 'p%'
The above query will retrieve all the products that have a description starting with "p" from the prodTable table.
Now, let's see which are the available wildcards.