Answer the question
In order to leave comments, you need to log in
SQL SELECT WHERE DATETIME = $year?
The table has an attribute called birthday.
You need to select those who were born in $year.
That is, if there is an entry birthday = 1995-05-07, and $year = 1995 Then it should get into the select.
ps Need the fastest implementation. I don’t know if it’s worth creating a separate year attribute if there is already a datetime ..
Answer the question
In order to leave comments, you need to log in
dev.mysql.com/doc/refman/5.5/en/date-and-time-func... Hold on. Can you guess how to use it or write a script?
UPD: On large volumes of rows - the use of such functions can mess up the query-plan a little. Alternatively, if you want to try to compare performance - you can try to make a selection like
WHERE birthday BETWEEN '1995-01-01' AND '1995-12-31'
SELECT YEAR(birthday) as year FROM blabla WHERE year = '1995';
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question