By 25/02/2016 15 Comments

AND & OR Operators In SQL

  • When you have multiple conditions in a WHERE clause in that situation the AND & OR operators can be used between these conditions.
  • The AND & OR operators are used to filter the result based on multiple conditions.
  • The AND & OR operators can also be used combine.

AND Operator:

  • The AND operator returns result sets if both conditions become true.

OR Operator:

  • The OR operator returns result sets if any one condition become true.

Syntax:

SELECT column_name
FROM table_name
WHERE column_name condition1 value operator id condition2 value;

Example: AND Operator

SELECT user_id, user_name
FROM sm_users
WHERE user_id = "5"
AND user_name = "demo admin";

Example: OR Operator

SELECT user_id, user_name
FROM sm_users
WHERE user_id = "55"
OR user_name = "demo admin";

Example: Combine used of AND & OR operators

SELECT user_id, user_name
FROM sm_users
WHERE user_id = "5"
AND (user_name = "demo admin" OR user_department = "I.T");






Posted in: Sql

Leave your valuable Comment

Have a natural attraction for women cosmetics and replica watches uk clothes, no
more than two for men the most attractive one, is to make their own driving experience, happy and can serve as the facade of the car, another is to highlight the taste edify sentiment rolex replica watch. The replica rolex is undoubtedly the most fashionable accessories, wear a suit to attend the activities, but also get a decent match on the replica watches .