I have a problem with my mysql query.
My database:
sections
id
section_name
grades
id
user_id
section_id
date
grade
I want my data
I recently had to do something similiar, but with T-SQL so you'll have to change it yourself to get it to work in MySQL (which I don't have installed here so I can't check for you I'm afraid).
Add to the WHERE clause:
AND grades.date = (SELECT TOP 1 date
FROM grades
WHERE date > GETDATE()
ORDER BY ABS(CONVERT(FLOAT,GETDATE() - date)))
GETDATE() is equivalent to NOW(), TOP 1 is like LIMIT 1 and the other functions, well I don't know the MySQL equivalents off the top of my head!