Note that there are some explanatory texts on larger screens.

plurals
  1. POSelecting data from three tables
    primarykey
    data
    text
    <p>Currently at the moment I have managed to join two tables to retrieve the information that is need. I have now decided to try and retrieve another piece of information from a another table ( users.user_id ) but the query I'm trying to use doesn't seem to work. If someone could help with the query would be great.</p> <p>Here is my current query that works fine.</p> <pre><code> "SELECT films.movie_title, films.rating, films.actor, reviewed.review FROM films INNER JOIN reviewed ON films.movie_id=reviewed.movie_id"; </code></pre> <p>Here is the query being used to get data from three tables but wont work</p> <pre><code> "SELECT films.movie_title, films.rating, films.actor, reviewed.review users.name FROM films OUTER JOIN reviewed, users ON films.movie_id=reviewed.movie_id &amp;&amp; films.user_id=users.user_id"; </code></pre> <p>Database: <code>film</code></p> <p>Table structure for table <code>films</code></p> <pre><code>CREATE TABLE IF NOT EXISTS `films` ( `movie_id` int(4) NOT NULL AUTO_INCREMENT, `movie_title` varchar(100) NOT NULL, `actor` varchar(100) NOT NULL, `rating` varchar(20) NOT NULL, `user_id` int(100) NOT NULL, PRIMARY KEY (`movie_id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ; INSERT INTO `films` (`movie_id`, `movie_title`, `actor`, `rating`, `user_id`) VALUES (1, 'batman', 'christian bale', 'Excellent', 3), (2, 'Bne', 'reee', 'Ok', 3), (3, 'Today', 'dd', 'Fair', 3); </code></pre> <p>Table structure for table <code>reviewed</code></p> <pre><code> CREATE TABLE IF NOT EXISTS `reviewed` ( `review_id` int(4) NOT NULL AUTO_INCREMENT, `review` mediumtext NOT NULL, `movie_id` int(4) NOT NULL, PRIMARY KEY (`review_id`), KEY `movie_id` (`movie_id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ; INSERT INTO `reviewed` (`review_id`, `review`, `movie_id`) VALUES (1, 'Wicked film', 1), (2, 'gedtg', 2), (3, 'dddd', 3); </code></pre> <p>Table structure for table <code>users</code></p> <pre><code> CREATE TABLE IF NOT EXISTS `users` ( `user_id` int(4) NOT NULL AUTO_INCREMENT, `email` varchar(40) NOT NULL, `password` varchar(40) NOT NULL, `name` varchar(30) NOT NULL, PRIMARY KEY (`user_id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=30 ; INSERT INTO `users` (`user_id`, `email`, `password`, `name`) VALUES (1, 'ben@talktalk.net', 'password', 'Ben'), (2, 'richard@talk.net', '1', 'richard'), </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload