MySQL Tutorial –MySQL AND & OR Operators

MySQL TutorialMySQL AND & OR Operators

AND operator is used to display records if both the first and second condition is TRUE. It can be used in SQL statement such as SELECT, UPDATE, DELETE.

AND operator syntax:

SELECT column_name(s)
FROM table_name
WHERE column_name=condition1 AND column_name=condition2;

Let’s see some example of AND operator:

Here is our database table: (employee_record)

[TABLE=3]

Retrieve the f_name and l_name of employees whose salary is greater than 20000 but not more than 60000. Issue the following command:

SELECT f_name, l_name from employee_record
WHERE salary > 20000 AND salary < 60000;

Result:

+---------+---------+
| f_name  | l_name  |
+---------+---------+
| Piolo   | Pascual |
| Rolan   | Algara  |
| Jericho | Rosales |
+---------+---------+
3 rows in set (0.05 sec)
, , ,

Post navigation

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.