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

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 168
    Comment on it

    These operators are used where we want to get records based on more than one condition .
    And : From this operator we can get data if both the condition ( i.e first and second condition ) are true .
    Or : From this operator we can get data if either the first condition or second is true .
    Example :
    Table name : Employee_Info

      Id        Employee_name          Employee_Age               Employee _Salary
      1            Mukesh                  23                           120000
      2            Ayush                   24                           200000
      3            Ishan                   40                           400000
      4            Pranav                  35                           123,00000
      5            Abhishek                26                           800000
      6            Ravi                    25                           300000
      7            David                   40                           8000
    

    Example of AND Operator :
    Query :

    select * from Employee_Info where Employee_Age = ' 40 ' and Employee_Salary = ' 8000 ' ;
    

    Output :

    Id        Employee_name          Employee_Age               Employee _Salary
    7            David                   40                           8000
    

    Example of OR Operator :
    Query :

    select * from Employee_Info where Employee_Age = ' 40 ' or Employee_Age = '  300000 ' ;
    

    Output :

    Id        Employee_name          Employee_Age               Employee _Salary
    6            Ravi                    25                           300000
    7            David                   40                           8000
    

    Example of Combining OR & And Operator :
    Query :

    select * from Employee_Info where Employee_Age = ' 40 ' and  ( Employee_Salary = ' 8000 ' or Employee_Salary = '  400000 ' ) ;
    

    Output :

    Id        Employee_name          Employee_Age               Employee _Salary
     3            Ishan                   40                           400000
     7            David                   40                           8000
    

 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: