0

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 !

4
  • please post few data and your desired output Commented Mar 29, 2019 at 14:36
  • use if/else statement Commented Mar 29, 2019 at 14:36
  • Maybe coalesce something like where coalesce(eventdate, movedate) >= ? not a PHP question though Commented Mar 29, 2019 at 14:37
  • Thanks a lot! I will try this Commented Mar 29, 2019 at 14:55

2 Answers 2

1

try this one like where coalesce(event_date, move_date) >= ?

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks a lot! I will try this.
0

use the "case" condition

SELECT CASE WHEN movedate != NULL THEN movedate ELSE eventdate END AS selecteddate

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.