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

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 192
    Comment on it

    This operator is used when we want specific pattern from a column in a table .
    % : This is called wildcards , it is used before and after the pattern .
    Syntax :

    select column_name1 .......column_nameN from table_name where column_name like pattern ;
    

    Example :
    Table name : Employee_Info

      Id        Employee_name          Employee_Age         Employee _Salary     City 
      1            Mukesh                  23                  120000            Meerut
      2            Ayush                   24                  200000            Baroda
      3            Ishan                   40                  400000            Multan
      4            Pranav                  35                  123,00000         Dehradun
      5            Abhishek                26                  800000            Mussoorie
      6            Ravi                    25                  300000           Pauri-Garhwal
      7            David                   40                  8000              Baghpat
    

    Example :
    Query :

    select * from Employee_Info where City like ' M% ' ;
    

    Output : All recods will come in which city is starting from letter M .

    Id        Employee_name          Employee_Age         Employee _Salary      City
    1            Mukesh                  23                  120000            Meerut
    3            Ishan                   40                  400000            Multan
    5            Abhishek                26                  800000            Mussoorie
    

    Example :
    Query :

    select * from Employee_Info where City like ' %n ' ;
    

    Output : All recods will come in which city is ending with letter n .

    Id        Employee_name          Employee_Age         Employee _Salary      City
     3            Ishan                   40                  400000            Multan
     4            Pranav                  35                  123,00000         Dehradun
    

    Example :
    Query :

    select * from Employee_Info where City like ' %ss% ' ;
    

    Output : All recods will come in which city containing the pattern " ss " .

    Id        Employee_name          Employee_Age         Employee _Salary      City
    5            Abhishek                26                  800000            Mussoorie
    

 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: