Quantcast
Channel: iNetTutor.com
Viewing all articles
Browse latest Browse all 1782

MySQL Tutorial – Using BETWEEN condition

$
0
0

Using BETWEEN condition

BETWEEN condition is used to retrieve records with in the given range.

The syntax of BETWEEN condition:

SELECT column_name(s)
FROM table_name
Where column_name
BETWEEN value1 AND value2;

Here is our example database table: (employee_record)

id f_name l_name position age salary email
1 Piolo Pascual Programmer 38 25000 piolopascual@yahoo.com
2 Sam Milby System Analyst 34 20000 sammilby@yahoo.com
3 John Lloyd Cruz Network Administrator 33 20000 johnllyodcruz@yahoo.com
4 Rolan Algara Encoder 19 55000 cuteness_tyron@yahoo.com
5 Jericho Rosales Encoder 25 55000 jerichorosales@yahoo.com
6 John Prats Programmer 24 15000 johnprats@yahoo.com

We want to select the firstname and lastname of the employees whose age is between 35-50. Issue the following command:

SELECT f_name, l_name
FROM employee_record
Where age
BETWEEN 35 AND 50;

Result:

+--------+---------+
| f_name | l_name  |
+--------+---------+
| Piolo  | Pascual |
+--------+---------+
1 row in set (0.00 sec)

Viewing all articles
Browse latest Browse all 1782

Trending Articles