Reputation: 2410
I have a database containing specific dates data like:
Date Event
----------------------------------
1st January 1980: Time of the Moon
21st January 1980: Celebration of Columbus
12th February 1980: Funeral of the Sun
I want to be able to query the database with:
select where day = 14, Month = January, and Year = 1980
Wherefore, the result should be: Time of the Moon
My problem is, since the data being selected doesn't exist, how do I achieve the above query?
Thanks.
Upvotes: 2
Views: 56
Reputation: 41968
SELECT Event
FROM MyTable
WHERE date(`Date`) <= '1980-01-14'
ORDER BY `Date` DESC
LIMIT 1;
Upvotes: 2