WHERE Clause of a SELECT Statement

This section provides tutorial examples on how to use the WHERE clause to filter rows out of the base table in a SELECT statement.

As I mentioned earlier, the WHERE clause modifies the base table by filtering out rows of data that do not satisfy the specified conditions. Here is its syntax:

WHERE where_condition

where "where_condition" is a predicate operation that will result a true or false condition.

WHERE clause samples:

WHERE Salary <= 45000.00
WHERE Salary > 45000.00 AND Salary <= 65000.00
WHERE Dept IN ('Math','Chem')
WHERE (Dept = 'Math' OR Dept = 'Chem') AND Salary <= 45000.00
WHERE User.Dept_ID = Dept.ID

Table of Contents

 About This Book

 Introduction of SQL

 MySQL Introduction and Installation

 Introduction of MySQL Programs

 PHP Programs and MySQL Server

 Perl Programs and MySQL Servers

 Java Programs and MySQL Servers

 Datatypes and Data Literals

 Operations and Expressions

 Character Strings and Bit Strings

 Commonly Used Functions

 Table Column Types for Different Types of Values

 Using DDL to Create Tables and Indexes

 Using DML to Insert, Update and Delete Records

Using SELECT to Query Database

 SELECT Statements

 FROM Clause of a SELECT Statement

 JOIN - Operation to Join Two Tables

 JoinTable.sql - Example of Join Tables

WHERE Clause of a SELECT Statement

 ORDER BY Clause of a SELECT Statement

 GROUP BY Clause of a SELECT Statement

 Window Functions for Statistical Analysis

 Use Index for Better Performance

 Transaction Management and Isolation Levels

 Locks Used in MySQL

 Defining and Calling Stored Procedures

 Variables, Loops and Cursors Used in Stored Procedures

 System, User-Defined and Stored Procedure Variables

 MySQL Server Administration

 Storage Engines in MySQL Server

 InnoDB Storage Engine - Primary and Secondary Indexes

 Performance Tuning and Optimization

 Bulk Changes on Large Tables

 MySQL Server on macOS

 Installing MySQL Server on Linux

 Connection, Performance and Second Instance on Linux

 Archived Tutorials

 References

 Full Version in PDF/EPUB