Fetch record by Year
date, mysql, php
Solution
try this one, use the MySQL `YEAR` function.
SELECT *
FROM tableName
WHERE YEAR(dateCOlumn) = 2012
so in the given example, the server will select all records where year is equal to 2012.
UPDATE 1
SQLFiddle Demo
YEAR
Problem
I have a form with a text field, where the user will provide the year only and MySQL data should return all the data for the given year. But in MySQL database, the `date` is given in `date(yyyy-mm-dd)` format. Can anyone suggest the SQL query which will fetch all the data for that particular year?