1. FROM Clause:
It is used to select the dataset which will be manipulated using Select, Update or Delete command.It is used in conjunction with SQL statements to manipulate dataset from source table.We can use subqueries in FROM clause to retrieve dataset from table.
Syntax of FROM clause:
SELECT * FROM TABLE_NAME;
2. WHERE Clause:
It is used to apply any condition on selected dataset or source data.Source data can be a single table or can be a result of joining multiple tables.It returns those instances of dataset which satisfies the condition mentioned in WHERE clause.Conditions can be applied using various comparison or logical operators like –
AND, OR, IN, NOT IN, BETWEEN, equals to, not equals to etc.
Syntax of WHERE clause:
SELECT * FROM TABLE_NAME WHERE (CONDITIONS);
Example:
Consider a table name STUDENT
| S_NO. | s_NAME | S_AGE | S_SECTION |
|---|---|---|---|
| 1 | Yash | 20 | A |
| 2 | Vishwash | 21 | A |
| 3 | Vishesh | 19 | B |
| 4 | Shivam | 23 | A |
| 5 | Vasu | 21 | B |
| 6 | Shrey | 20 | C |
Problem:
We have to select those instances of table STUDENT where age is less than 22 and section is A.
Query:
SELECT * FROM STUDENT WHERE S_AGE<22 AND S_SECTION='A';
OUTPUT:
Here FROM clause chooses the table on which the WHERE clause should be applied and WHERE clause checks the two condition to find which instances of the dataset are satisfying them.
| S_NO. | s_NAME | S_AGE | S_SECTION |
|---|---|---|---|
| 1 | Yash | 20 | A |
| 2 | Vishwash | 21 | A |
Differences between FROM Clause and WHERE Clause :
| S_NO. | FROM Clause | WHERE Clause |
|---|---|---|
| 1. | It is used to select the dataset on which manipulation has to be done. | It is used for checking some conditions to filter result |
| 2. | We provide some dataset into the FROM clause as a input. | In WHERE clause we give some condition as input. |
| 3. | FROM clause selects dataset to provide it to WHERE clause for applying conditions given in query. | WHERE clause act as selector which filters required instances from dataset provide by FROM clause. |
| 4. | FROM clause is mandatory because if there is no dataset, no manipulation can be performed. | WHERE is optional, we use it only in case of condition checking. |
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
Recommended Posts:
- Difference between Having clause and Group by clause
- Difference between Where and Having Clause in SQL
- Difference between order by and group by clause in SQL
- SQL | WHERE Clause
- SQL | Except Clause
- SQL | WITH clause
- SQL | USING Clause
- Having vs Where Clause in SQL
- SQL | ON Clause
- SQL | With Ties Clause
- SQL | Union Clause
- SQL | SELECT TOP Clause
- Having clause in MS SQL Server
- SQL | Intersect & Except clause
- SQL | Distinct Clause
- PHP | MySQL WHERE Clause
- Where clause in MS SQL Server
- SQL | LIMIT Clause
- SQL | Sub queries in From Clause
- PHP | MySQL ORDER BY Clause
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

