
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
How to use MySQL Date functions with WHERE clause?
By using the WHERE clause with any of the MySQL date functions, the query will filter the rows based on the condition provided in the WHERE clause. To understand it, consider the data from ‘Collegedetail’ table as follows
mysql> Select * from Collegedetail; +------+---------+------------+ | ID | Country | Estb | +------+---------+------------+ | 111 | INDIA | 2010-05-01 | | 130 | INDIA | 1995-10-25 | | 139 | USA | 1994-09-25 | | 1539 | UK | 2001-07-23 | | 1545 | Russia | 2010-07-30 | +------+---------+------------+ 5 rows in set (0.00 sec)
Now, suppose if want to get the details of only those colleges which established in the year 2010 then following query, having WHERE clause with YEAR(), can be used −
mysql> Select * from Collegedetail WHERE YEAR(Estb) = '2010'; +------+---------+------------+ | ID | Country | Estb | +------+---------+------------+ | 111 | INDIA | 2010-05-01 | | 1545 | Russia | 2010-07-30 | +------+---------+------------+ 2 rows in set (0.07 sec)
- Related Articles
- How to use MySQL VIEW with WHERE clause?
- How Can we use MySQL DISTINCT clause with WHERE and LIMIT clause?
- How MySQL LTRIM() and RTRIM()functions can be used with WHERE clause?
- How can we use two columns with MySQL WHERE clause?
- How can we use ASCII() function with MySQL WHERE clause?
- How can we use CHAR_LENGTH() function with MySQL WHERE clause?
- How can we use BIN() function with MySQL WHERE clause?
- How can we use FIND_IN_SET() function with MySQL WHERE clause?
- How can we use MySQL INSTR() function with WHERE clause?
- How can I use SPACE() function with MySQL WHERE clause?
- How can we use WHERE clause with MySQL INSERT INTO command?
- Condition to check for due date and current date records in MySQL where clause
- How can we use MySQL REVERSE() function on column’s data along with WHERE clause?
- Can we use WHERE clause inside MySQL CASE statement?
- How can MySQL REPLACE() function be used with WHERE clause?

Advertisements