Search system with Inner Join

Asked

Viewed 105 times

1

I created a search system.

Tabela Sessions
 ID - NAME - SESS - EPISODE

Tabela Movie
 ID - Movie_id, Movie_Name

What I intend to do is make a select thus:

SELECT id, name, sess, episode FROM sessions WHERE name LIKE '%" . $name . "%' AND user_id ='$sessionID'

Only instead of looking for the name, seeks the Movie_Name. That is, it seeks the name (sessions) and tell me if it’s the same as Movie_id (movies), if it is shows the movie_name.

2 answers

0

Just specify in INNER JOIN what the relation between the tables. In case you want only the data of the tables where sessions.movie_name = movie.movie_id.

SELECT movie_name 
FROM movie 
INNER JOIN sessions 
    ON sessions.movie_name = movie.movie_id 
WHERE movie_name LIKE '%" . $name . "%' 
AND user_id ='$sessionID'
  • this error appears, how do I add ID and NAME to do in Loop afterwards? ->> Notice : Undefined index: id in C: xampp htdocs htdocs library.php on line 269 Notice : Undefined index: name in C: xampp htdocs htdocs library.php on line 269

0

Since this error appears, how do I add the ID and NAME fields from the "Sessions" table to do in Loop afterwards? I already add after ON but gives error.

->>> Notice : Undefined index: id in C: xampp htdocs htdocs library.php on line 269 Notice : Undefined index: name in C: xampp htdocs htdocs library.php on line 269

Browser other questions tagged

You are not signed in. Login or sign up in order to post.