Search system with Inner Join

1

I created a search engine.

Tabela Sessions
 ID - NAME - SESS - EPISODE

Tabela Movie
 ID - Movie_id, Movie_Name

What I want is to do a select like this:

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

Instead of looking at name , look for Movie_Name . That is, look for name ( sessions ) and say if it is equal to Movie_id ( movies ), if it shows movie_name .

    
asked by anonymous 05.06.2017 / 11:06

2 answers

0

Simply specify in INNER JOIN the relationship between 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'
    
05.06.2017 / 11:53
0

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

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

    
05.06.2017 / 16:07