Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • SQL wildcards

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 416
    Comment on it

    SQL wildcards are used within a table to search for data.  Usage of wildcard characters in SQL call for SQL LIKE operator, which enables to hold a comparison between a value and similar values.

    Following are the two types of wildcard operators :

    The percent sign (%) : Matches one or more characters. 

    Syntax: 

    1. SELECT FROM table_name
    2. WHERE column LIKE 'XXXX%'
    3.  
    4. or
    5.  
    6. SELECT FROM table_name
    7. WHERE column LIKE '%XXXX%'
    8.  

     

    E.g: 

    1.  

    1. WHERE SALARY LIKE '500%'

    Finds any values that start with 500

     

    2.

    1. WHERE SALARY LIKE '%600%'

    Finds any values that have 600 in any position.

     

    3.

    1. WHERE SALARY LIKE '%5'

    Finds any values that end with 5.

     

    The underscore (_) : Matches one character.

    Syntax: 

    1. SELECT FROM table_name
    2. WHERE column LIKE 'XXXX_'
    3.  
    4. or
    5.  
    6. SELECT FROM table_name
    7. WHERE column LIKE '_XXXX'
    8.  
    9. or
    10.  
    11. SELECT FROM table_name
    12. WHERE column LIKE '_XXXX_'

     

    E.g.

    1.

    1. WHERE SALARY LIKE '4___8'

    Finds any values in a five-digit number that start with 4 and end with 8.

     

    2.

    1. WHERE SALARY LIKE '_00%'

    Finds any values that have 00 in the second and third positions.

     

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Reset Password
Fill out the form below and reset your password: