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

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 294
    Comment on it

    It is used with the like operator to compare the values of the type similar.

    It support two wildcards type

    1. The percent sign (%)- It match to one or more character.

    2. The underscore (_)- It match to one character.

     

    The percent sign represents zero, one, or multiple characters. The underscore represents a single number or character. The symbols can be used in combinations.

    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_' 
    or
     SELECT FROM table_name WHERE column LIKE '_XXXX'
    or
     SELECT FROM table_name WHERE column LIKE '_XXXX_'

    ex

    +----+----------+-----+-----------+----------+
    | ID | NAME     | AGE | ADDRESS   | SALARY   |
    +----+----------+-----+-----------+----------+
    |  1 | Ramesh   |  32 | Ahmedabad |  2000.00 |
    |  2 | Khilan   |  25 | Delhi     |  1500.00 |
    |  3 | kaushik  |  23 | Kota      |  2000.00 |
    |  4 | Chaitali |  25 | Mumbai    |  6500.00 |
    |  5 | Hardik   |  27 | Bhopal    |  8500.00 |
    |  6 | Komal    |  22 | MP        |  4500.00 |
    |  7 | Muffy    |  24 | Indore    | 10000.00 |
    +----+----------+-----+-----------+----------+
    SQL> SELECT * FROM CUSTOMERS WHERE SALARY LIKE '200%';

    The result is it

    +----+----------+-----+-----------+----------+
    | ID | NAME     | AGE | ADDRESS   | SALARY   |
    +----+----------+-----+-----------+----------+
    |  1 | Ramesh   |  32 | Ahmedabad |  2000.00 |
    |  3 | kaushik  |  23 | Kota      |  2000.00 |
    +----+----------+-----+-----------+----------+

 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: