sql where clause and condition

Always we don't want all records from table. So selecting required records, we use WHERE clause.

Here is syntax:

SELECT col_name1,col_name2 FROM table_name WHERE "condtion"

Suppose we have table with name employees

id first_name last_name salary city
1 Johan Sumith 200000 Delhi
2 Ansh Kumar 300000 Mumbai
3 Sameer Seth 100000 Delhi
4 Pyush   250000 Kolkata

Now we want records of those employees in which live in delhi

SELECT * FROM employees WHERE city='Delhi'

The result is

id first_name last_name salary city
1 Johan Sumith 200000 Delhi
3 Sameer Seth 100000 Delhi

In comming example we want to see records of those employees whose salary is greater than 200000

SELECT * FROM employees WHERE salary>200000

The result is

id first_name last_name salary city
2 Ansh Kumar 300000 Mumbai
4 Pyush   250000 Kolkata