Home > DeveloperSection > Articles > SQL Wildcards

SQL Wildcards

Posted by  Arun Singh
on    July-04-2011 14:44 PM

Database Database 
Ratings:
0 Comment(s)
 2197  View(s)
Rate this:

SQL Wildcards

SQL wildcards are used for searching one or more characters from table in a database. The SQL wildcards substitute one or more character, whenever there is a search for data in a table of the database. The Wildcards is must be used with LIKE operator. 

  There are many wildcards are used in SQL database, Here in which some important wildcards are given below:

1.     ‘%’ wildcards:

     ‘%’ allows you to match any string of any length that means a substitute for zero or more characters.

Example:    

Now we want to select the User whose name that starts with "ar" from the "userlogininfo" table.

 Select Query:    select username from userlogininfo where UserName like 'ar%' Output:

ArunKumar

Arunsingh

2.     ‘_’ wildcards:

‘_ ‘allows you to match on a single character that means ‘_’is looking for only one character.

 Example: 

 Now we want to select the user with a first name that starts with any character, followed by "runsingh" from the "userlogininfo" table.

 Select Query:  select username from userlogininfo where UserName like _runsingh'

Output:

                Arunsingh

3.     [charlist] wildcards:

[charlist] wildcards are used for any single character in charlist.

   Example:

Now we want to select the user with a name that starts with "a" or "v" from the "userlogininfo" table.

  Select Query:  select username from userlogininfo where UserName like '[av]%'

Output:

                ArunKumar

Arunsingh

Varunsingh
















Recent Activities


Kamlakar Singh added new Blog Convert Text Document to PDF File   11 days ago

Kamlakar Singh added new Article Introduction to Backbone.js   11 days ago

Kamlakar Singh added new Question Explain the AdRotator Control.   11 days ago

Don't want to miss updates? Please click the below button!