Reputation: 31
Now, I've a problem with the following query:
SELECT *
FROM table
WHERE date > CURDATE()
OR date = CURDATE()
AND time > CURTIME()
It's return rows with date > of today but I need also rows with date of today but with time > of the current time.
Upvotes: 2
Views: 46
Reputation: 43434
You should use the appropriate date/time functions instead of complicating yourself with complex WHERE
clauses:
SELECT * FROM TABLE
WHERE ADDTIME(date, time) > NOW()
More information on the ADDTIME
function in this link.
Upvotes: 0
Reputation: 80629
You need to put the related clauses inside parenthesis:
SELECT *
FROM table
WHERE date > CURDATE()
OR (
date = CURDATE()
AND time > CURTIME()
)
Upvotes: 1