ASK Question

Quick links:
Latest articles
Internship
Members

Languages:
C
C++
C++ STL
Java
Data Structure
C#.Net
Android
Kotlin
SQL

Web:
PHP
Python
JavaScript
CSS
Ajax
Node.js
Web prog.

Programs:
C
C++
DS
Java
C#
Python


Aptitude:
C
C++
Java
DBMS

Interview:
C
Embedded C
Java
SEO
HR

CS Subjects:
CS Basics
O.S.
Networks
DBMS
Embedded Systems
Cloud Computing
Machine learning
CS Organizations
Linux
DOS

More:
Articles
Puzzles
News/Updates


Home » SQL

SQL - WHERE Clause (to filter data)



SQL - WHERE Clause: Here, we will learn how to filter data from a table (it is used to check conditions).
Submitted by Shubham Singh Rajawat, on November 14, 2017

WHERE clause is used to filter the data by means of conditions. It is used to fetch records that fulfil a certain criteria. WHERE clause can be used with SELECT, UPDATE, DELETE etc.

Syntax:

SELECT column1, column2, ... FROM table_name WHERE condition;

Here,

  • column1, column2,…: are the name of the fields in the table
  • table_name: name of the table from which we want to fetch data
  • condition: this condition is used to filter the data. It can be break into three parts (Column_name operator value).

Sample table (Student),

alter table in sql example

Examples:

1) Fetch Student whose physics marks are 91

SELECT * FROM Student WHERE physics=91;
WHERE CLAUSE in sql example

2) Fetch Student whose DOB is between 1997-06-01 and 1998-11-01

SELECT * FROM Student WHERE DOB BETWEEN '1997-06-01' and '1998-11-01';

Will Fetch student whose DOB lies in between the given dates both inclusive.

WHERE CLAUSE in sql example

3) Fetch Student where city is Delhi and Gwalior

SELECT * FROM Student WHERE City IN ('Gwalior', 'Delhi');

Will fetch students who live in Gwalior and Delhi.

WHERE CLAUSE in sql example

4) Fetch Student whose name start with 'a'

SELECT * FROM Student WHERE Student_name LIKE 'A%';

This will fetch students whose name starts with 'A'.

WHERE CLAUSE in sql example





Quick links:
C FAQ(s) C Advance programs C/C++ Tips & Tricks Puzzles JavaScript CSS Python Linux Commands PHP Android Articles More...

Was this page helpful? Please share with your friends...

Are you a blogger? Join our Blogging forum.

Comments and Discussions




Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing » Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com (2015-2018), Some rights reserved.