0

我在查询中有问题。我需要创建一个页面,用户可以在其中查看他使用电影名称、电影院名称、他预订的座位代码进行的所有预订

我达到了这个水平

SELECT member.member_username, show_datetime, movie_name
FROM `member`
JOIN `reservation` ON `reservation`.`member_id` = `member`.`member_id`
JOIN `show` ON `show`.`show_id`= `reservation`.`show_id`
JOIN `movie` ON `movie`.`movie_id` = `show`.`movie_id`
WHERE `reservation`.`member_id`=1

我需要建立连接并从电影院表中获取cinema_name,从座位表和剧院名称中获取seat_code 事实上,我需要一个查询来给我整个数据库中的几乎所有数据

这是数据库 http://imageshack.us/photo/my-images/824/58054944.jpg/的架构

4

2 回答 2

1

JOIN这两个表也是:

SELECT 
  m.member_username, 
  sh.show_datetime, 
  v.movie_name,
  c.cinema_name,
  t.theater_name
FROM member            AS m
INNER JOIN reservation AS r  ON r.member_id  = m.member_id
INNEr JOIN show        AS sh ON sh.show_id   = r.show_id
INNER JOIN movie       AS v  ON v.movie_id   = s.movie_id
INNER JOIN theater     AS t  ON t.theater_id = sh.theater_id
INNER JOIN cinema      AS c  ON c.theater_id = sh.theater_id 
WHERE r.member_id = 1
于 2013-04-15T19:22:02.260 回答
1

继续加入你的桌子

SELECT member.member_username, show_datetime, movie_name, c.cinema_name, t.theater_name
FROM `member`
    JOIN `reservation` ON `reservation`.`member_id` = `member`.`member_id`
    JOIN `show` ON `show`.`show_id`= `reservation`.`show_id`
    JOIN `movie` ON `movie`.`movie_id` = `show`.`movie_id`
    JOIN `theater` ON `show`.`theater_id` = `theater`.`theater_id`
    JOIN `cinema` ON `theater`.`cinema_id` = `cinema`.`cinema_id`
    JOIN `seat` ON `show`.`theater_id` = `seat`.`theater_id`
WHERE `reservation`.`member_id`=1
于 2013-04-15T19:24:03.723 回答