Topic awaiting preservation: help with SQL query please (Page 1 of 1) |
|
---|---|
Maniac (V) Inmate From: there...no..there..... |
posted 09-09-2006 23:04
I have a database like this : code: +----------------+ | Movies | +----------------+ | movie | | movietype | | people | +----------------+
code: +--------------------+ | People | +--------------------+ | people_id | | people_fullname | | peple_isactor | | people_isdirector | +--------------------+
code: "SELECT movie.movie_name, movie.movie_year, movietype.movietype_label, people.people_fullname " . "FROM movie, movietype, people " . "WHERE movie.movie_type = movietype_id AND people.people_id = movie.movie_leadactor " . "ORDER BY movie.movie_type";
|
Paranoid (IV) Inmate From: INFRONT OF MY PC |
posted 09-09-2006 23:47
Add AND people.´people_id = movie.movie_director ??? |
Maniac (V) Inmate From: there...no..there..... |
posted 09-09-2006 23:55
tried that. comes back with 0 entires |
Paranoid (IV) Mad Librarian From: Glieberlermany |
posted 09-10-2006 00:19
Perhaps code: "SELECT movie.movie_name, movie.movie_year, movietype.movietype_label, people1.people_fullname, people2.people_fullname " . "FROM movie, movietype, people AS people1, people AS people2 " . "WHERE movie.movie_type = movietype_id AND people1.people_id = movie.movie_leadactor and people2.people_id = movie.movie_director" . "ORDER BY movie.movie_type";
|
Maniac (V) Inmate From: there...no..there..... |
posted 09-10-2006 02:20
i thought you had it there kuckus. the people2.people_id = movie.movie_director returned 0 results. |
Bipolar (III) Inmate From: |
posted 09-10-2006 07:13
Hey CP, code: "SELECT movie.movie_name, movie.movie_year, movietype.movietype_label, directors.people_fullname, actors.people_fullname " . "FROM movie, movietype" . "LEFT JOIN people AS actors ON people.people_id = movie.movie_leadactor" . "LEFT JOIN people AS directors ON people.people_id = movie.movie_director" . "WHERE movie.movie_type = movietype.movietype_id" . "ORDER BY movie.movie_type";
|
Maniac (V) Mad Scientist with Finglongers From: Germany |
posted 09-10-2006 09:15
Sorry to tell you, but your database setup flawed. code: Select movie.movie_name, people.people_fullname, people_isActor, people.is_Director ( personally, I hate that prefixing. We're alreading accessing a table called people...) from movies, people, movieToPeople where movies.movieId = movieToPeople.movieId AND movieToPeople.peopleId = people.peopleId
|
Paranoid (IV) Inmate From: INFRONT OF MY PC |
posted 09-10-2006 11:26
Ok think i made a mistake with my anser try OR instead of AND |
Maniac (V) Inmate From: there...no..there..... |
posted 09-10-2006 15:51
TP, I think you are right. I'll give the extra table a shot and see what I can come up with. Thanks! |