How do i run inner join and make variables which show dynamic page in php
i have 6 tables in database movie_info
, star_info
, classification_info
, director_info
,
genre_info
, studio_info
.
where star_info
, classification_info
, director_info
, genre_info
, studio_info开发者_如何学Python
are main tables which hold all the information for movies-star
, Classification, director of movies and movies table only contain the FK of those tables.
now I wants to do is Show in my php page all the movies which stored in my movie_info table with Directors, stars, genre... FK from 5 above tables. note that movie_info table only has ID field of Direcor and stars not the name so i have run the inner join to get name.
sql = mysql_quary("
SELECT
movie_info.movie_id, movie_info.movie_name, movie_info.tagline, movie_info.plot, star_info.star_name
FROM movie_info
INNER JOIN star_info
ON movie_info.star_id = star_info.id
")
Now my question is how can i Use this names and show to php page, I mean I will be having Five different queries (Director, Gener, Classification) which will need to get name from their own table and come back to show their name instead of their FK which has been stored in movie_info
table.
To run multiple inner joins its really easy, here is the basic structure of how its done.
SELECT * FROM table1 INNER JOIN table2 ON table1.value1 comp[=, <, >, <=, >=] table2.value1 INNER JOIN table3 ON table1.value2 comp[=, <, >, <=, >=] table3.value1
So that should solve your problem.
精彩评论