-4

我有以下数据库结构:

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

每个房间类别有几个季节/价格,我需要找到一个查询来连接这 3 个表,如下例所示:

season              room_categories     prices 

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

创建此类查询的最佳方法是什么?提前致谢。

4

1 回答 1

0

像这样的查询会有所帮助。

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 = '?'

享受吧,别忘了给极客小费。

于 2013-08-31T02:05:42.773 回答