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

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 312
    Comment on it

    <-- Chapter 15: SQL <= Operator

    Chapter 16

    SQL And & Or


    AND/OR Operators are used in SQL statements to filter the Records based on more than one condition. AND Operator display the records in which all the specified conditions are TRUE. OR Operator display the records in which any one of the condition is TRUE

    Lets see an example from the below table "employees" :-


    employee_id name code designation salary
    101 ABC E-101 Engineer 12000
    102 DEF E-102 Doctor 8000
    103 GHI E-103 Software Developer 8000
    104 JKL E-104 CEO 12000
    105 MNO E-105 Software Developer 100000

    AND SQL Statement Example :-


    SELECT * 
    FROM `employees`
    WHERE `name` = 'ABC' AND `name` = 'MNO' ;
    

    Now Run this Query, we will see the output below :-


    employee_id name code designation salary
    101 ABC E-101 Engineer 12000
    105 MNO E-105 Software Developer 100000


    We can see here, that only those records are displayed which column name values matches 'ABC' and 'MNO'.


    OR SQL Statement Example :-


    SELECT * 
    FROM `employees`
    WHERE `name` = 'DEF' OR `name` = 'PQR' ;
    

    Now Run this Query, we will see the output below :-


    employee_id name code designation salary
    102 DEF E-102 Doctor 8000

    We can see here, that only those records are displayed which column name values matches either 'DEF' or 'PQR'.


    Chapter 17: SQL ORDER BY -->

 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: