MySQL Dynamicly determine the tabel to use with inner join
- by user366990
He guys, I'm stuck with a problem and I hope someone can help me out. I have a date. For example 2009-10-1. This date is used to check in which season I am working. This could be summer or winter.
If whe are in the summer the table to use for my inner join whould be 'summer09_rooms'. If winter 'winter09_rooms'. So I basicly whant to do a CASE WHEN in my INNER JOIN. How to accomplish this. The query would look like this:
SELECT name, arrival_date, departure_date FROM holliday a
INNER JOIN
(
CASE when arrival_date BETWEEN 2009-10-1 AND 2009-4-1 THEN summer09_rooms b
ELSE winter09_rooms b END
)
ON a.dossier=b.dossier
Of course this query isn't working but now I hope you'l see what I want to accomplish.
Kind regards,
Digital Human