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

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 388
    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: 

    SELECT FROM table_name
    WHERE column LIKE 'XXXX%'
    
    or 
    
    SELECT FROM table_name
    WHERE column LIKE '%XXXX%'
    

     

    E.g: 

    1.  

    WHERE SALARY LIKE '500%'

    Finds any values that start with 500

     

    2.

    WHERE SALARY LIKE '%600%'

    Finds any values that have 600 in any position.

     

    3.

    WHERE SALARY LIKE '%5'

    Finds any values that end with 5.

     

    The underscore (_) : Matches one character.

    Syntax: 

    SELECT FROM table_name
    WHERE column LIKE 'XXXX_'
    
    or
    
    SELECT FROM table_name
    WHERE column LIKE '_XXXX'
    
    or
    
    SELECT FROM table_name
    WHERE column LIKE '_XXXX_'

     

    E.g.

    1.

    WHERE SALARY LIKE '4___8'

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

     

    2.

    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
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: