0

I have a problem in a query. i need to make a page where user can see all reservations he made with movie name, cinema name, seats code that he reserved

i reached this level

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

i need to make a connection and get also the cinema_name from cinema table and seats_code from seat table and theater name in fact, i need a query to give me all almost all data in my whole database

here is the schema for the DB http://imageshack.us/photo/my-images/824/58054944.jpg/

5
  • why don't you keep joining tables? Commented Apr 15, 2013 at 19:16
  • So, what's the question? Does this query not work? Commented Apr 15, 2013 at 19:16
  • @RocketHazmat it is working but i need more data from more tables...i did a serie of joining table from member -->movie...but i still need to use theater, cinema and seat table Commented Apr 15, 2013 at 19:20
  • i still don't understand the question? join theater to show like your ERD shows. Commented Apr 15, 2013 at 19:21
  • @ouzoumzak: Just keep JOINing :-) Commented Apr 15, 2013 at 19:23

2 Answers 2

1

JOIN these two tables too:

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
Sign up to request clarification or add additional context in comments.

Comments

1

Keep joining your tables

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

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.