VOOZH about

URL: https://www.geeksforgeeks.org/sql/difference-between-from-and-where-clause-in-sql/

⇱ Difference between From and Where Clause in SQL - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Difference between From and Where Clause in SQL

Last Updated : 3 May, 2020
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 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. Differences between FROM Clause and WHERE Clause :
Comment
Article Tags:
Article Tags: