Reputation: 23
In my database, I have 2 different dates. A move date and a event date. I would like to run a query by event date. But if there is no event date, so i want use the move date. Is there a MYSQL code that does this? Like this: "where if .." Of course the result is in descending order date. Thanks !
Upvotes: 0
Views: 69
Reputation: 153
use the "case" condition
SELECT CASE WHEN movedate != NULL THEN movedate ELSE eventdate END AS selecteddate
Upvotes: 0
Reputation: 99
try this one like where coalesce(event_date, move_date) >= ?
Upvotes: 1