Using
WHERE clause you can get the records based on a condition.
Syntax
SELECT
column1, column2, … columnN FROM table_name WHERE [condition]
1. Select
employee details, where name is krishna.
mysql> select * from employee WHERE firstName="Krishna"; +----+-----------+----------+--------+---------------------+ | id | firstName | lastName | salary | mailId | +----+-----------+----------+--------+---------------------+ | 1 | Krishna | Ananda | 100000 | krishna@krishna.com | +----+-----------+----------+--------+---------------------+ 1 row in set (0.07 sec)
2. Select
employee details, where salary is greater than 10000.
mysql> select * from employee WHERE salary > 10000; +----+-----------+-----------+--------+---------------------+ | id | firstName | lastName | salary | mailId | +----+-----------+-----------+--------+---------------------+ | 1 | Krishna | Ananda | 100000 | krishna@krishna.com | | 2 | Arjun | Dhanunjay | 50000 | arjun@arjun.com | | 3 | Ptr | Ptr | 25000 | ptr@ptr.com | +----+-----------+-----------+--------+---------------------+ 3 rows in set (0.00 sec)
3. Select
employee details, where salary is 25000 and firstName is Ptr.
mysql> select * from employee WHERE (salary = 25000 AND firstName="Ptr"); +----+-----------+----------+--------+-------------+ | id | firstName | lastName | salary | mailId | +----+-----------+----------+--------+-------------+ | 3 | Ptr | Ptr | 25000 | ptr@ptr.com | +----+-----------+----------+--------+-------------+ 1 row in set (0.00 sec)
No comments:
Post a Comment