-4

I have the following database structure:

season             prices             room_categories    
---------------    ---------------    ---------------
id                 id                 id
name               season_id          name
date_from          category_id
date_to            price

There are several seasons / prices for each room category and I need to find a query which joins those 3 tables like in the following example:

season              room_categories     prices 

                    id -------------->  category_id
id ---------------------------------->  season_id

What would be the best way to create such an query? thanks in advance.

Exwolf
  • 157
  • 1
  • 12
Fuxi
  • 329
  • 2
  • 6
  • 15

1 Answers1

0

A query like this will help.

SELECT * FROM season AS t1
LEFT JOIN prices AS t2 ON t1.id = t2.season_id
LEFT JOIN room_categories AS t3 ON t2.category_id = t3.id
WHERE t1.id = '?'

Enjoy, don't forget to tip the geek.

Jason
  • 1,987
  • 1
  • 14
  • 16