Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • Databases
  • SQL
  • MySQL
  • PostgreSQL
  • PL/SQL
  • MongoDB
  • SQL Cheat Sheet
  • SQL Interview Questions
  • MySQL Interview Questions
  • PL/SQL Interview Questions
  • Learn SQL and Database
Open In App
Next Article:
Difference between Where and Having Clause in SQL
Next article icon

Difference between From and Where Clause in SQL

Last Updated : 03 May, 2020
Comments
Improve
Suggest changes
Like Article
Like
Report

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.



Next Article
Difference between Where and Having Clause in SQL
author
ypsjnv2013
Improve
Article Tags :
  • DBMS
  • Difference Between
  • GATE CS
  • SQL

Similar Reads

  • Difference between Where and Having Clause in SQL
    In SQL, the WHERE and HAVING clauses are essential for filtering data and refining query results. While both serve the purpose of applying conditions, they are used at different stages of query execution and for distinct purposes. Understanding the differences between the WHERE and HAVING clauses is
    4 min read
  • Difference between View and Cursor in SQL
    1. View : A view is a virtual table that not actually exist in the database but it can be produced upon request by a particular user. A view is an object that gives the user a logical view of data from a base table we can restrict to what user can view by allowing them to see an only necessary colum
    3 min read
  • Difference Between Order By and Group By Clause in SQL
    SQL provides powerful tools for organising and analysing data, and two commonly used clauses are ORDER BY and GROUP BY. The ORDER BY clause is used to sort data, while the GROUP BY clause is used to group rows with similar values, often combined with aggregate functions like SUM(), AVG(), or COUNT()
    5 min read
  • Difference Between Where and Group By
    WHERE and GROUP BY clauses are essential tools for filtering and organizing data in SQL queries. While both are used to refine the output of a query, they serve distinct purposes. In this article, we will explore the differences between WHERE and GROUP BY clauses, including their syntax, use cases,
    4 min read
  • Difference Between JOIN, IN and EXISTS Clause in SQL
    SEQUEL widely known as SQL, Structured Query Language is the most popular standard language to work on databases. We can perform tons of operations using SQL which includes creating a database, storing data in the form of tables, modify, extract and lot more. There are different versions of SQL like
    4 min read
  • Difference between Simple and Complex View in SQL
    A View in SQL as a logical subset of data from one or more tables. Views are used to restrict data access. A View contains no data of its own but it is like a window through which data from tables can be viewed or changed. The table on which a View is based is called BASE Tables. There are 2 types o
    2 min read
  • Difference between DBMS and SQL
    1. Database management system (DBMS) :Database management system (DBMS) is a software that manage or organize the data in a database. We can arrange the data in a tabular form (i.e. in row or column). It helps the user to retrieve the data from the database.Best examples of DBMS are - MYSQL, ORACLE,
    2 min read
  • Difference Between Having Clause and Group by Clause
    SQL is a powerful tool for data analysis, and mastering the nuances of the GROUP BY and HAVING clauses is essential for writing efficient queries. These clauses work together to group and filter data, enabling users to derive meaningful insights from datasets. In this article, we will explore the de
    4 min read
  • Difference between SQL and T-SQL
    SQL (Structured Query Language) is the standard language for managing and manipulating relational databases, enabling operations like querying, updating, and deleting data. T-SQL (Transact-SQL), an extension of SQL developed by Microsoft, adds advanced features and procedural capabilities specifical
    4 min read
  • Difference between JOIN and UNION in SQL
    Pre-requisites: JOIN, UNION JOIN in SQL is used to combine data from many tables based on a matched condition between them. The data combined using the JOIN statement results in new columns. Consider the two tables: Boys Girls Example: sql> SELECT Boys.Name, Boys.Age, Girls.Address, FROM Boys INN
    2 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences