MySQL Forums
Forum List  »  Newbie

SQL Query Question
Posted by: Brian Oliver
Date: July 31, 2005 07:02PM

Hello again,

I have created a profile page where I can just enter the information and the page will create itself filling in the blanks. Well, I didn't have a problem getting the names, birth dates, etc but this one query I can't get right to sort out the actor's films, as is, it's listing all the movies in my "movie_table".

Here's the code:

$sOrderBy = $_GET['order'];

$ad = $_GET['ad'];

$id = $_GET['id'];

$result = @mysql_query('SELECT MovieTitle, ReleaseDate, Gross FROM movie_table, actor_movie_table, actor_table WHERE actor_table.ActorID='.$id.' AND actor_movie_table.ActorID = actor_movie_table.MovieID ORDER BY '.$sOrderBy.' '.$ad.'');

and the pages:
http://www.moviemansguide.com/profiles/profile.php?id=1&order=ReleaseDate&ad=desc

http://www.moviemansguide.com/profiles/profile.php?id=2&order=ReleaseDate&ad=desc


Now, I know what the problem is. The "actor_movie_table.ActorID = actor_movie_table.MovieID". Note: actor_movie_table is my third table which has its own id as well as the id for the actor and corresponding movie. I've tried a few different things, but don't know the right syntax so that it all separates properly.

Options: ReplyQuote


Subject
Written By
Posted
SQL Query Question
July 31, 2005 07:02PM
July 31, 2005 07:09PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.