Ok I need some help. I never really used JOIN in my programming but nog im forced to do so or else I would get a lot of double information. I have 2 tables: Genre: id genre Movieid Movies id (sames as movieid in the genre table) lot of inforows Code (markup): I need a query that selects info out of the Movies table but I need to sort it by genre (which is in the genre table). I tried this: $query = "SELECT * FROM movies JOIN genres ON genres.movieid=movies.id WHERE genres.genre='$this->search'"; Code (markup): But it turns out empty. What am I doing wrong and what should I do ???? Thnx in advance !
I think you need to rewrite your php code to something like this $query = "SELECT * FROM movies JOIN genres ON genres.movieid=movies.id WHERE genres.genre='".$this->search."'"; Code (markup):
$query = "SELECT * FROM movies LEFT JOIN genres ON movies.id = genres.movieid WHERE genres.genre='$this->search'"; Code (markup): if it isnt working, what is the error you are getting? EDIT: is it genres or genre? your sql had genres but you say your table name is genre
I spoke to soon it doesnt work. For a second I thought it did but a refresh learned me that I was viewing a cache version. Its not in the word genres, I checked the databases match. Please help as im lost here. First time I use JOIN and it goes horribly wrong, lol EDIT: I got it working, thnx for the help everyone