Joining tables
Posted by:
A A
Date: May 18, 2020 04:10PM
Hello good afternoon I am currently practicing some Mysql and had a question about FILTERIING THE RESULTS ON JOINED TABLES. what im trying to achieve is filter my results. to show which actor appeared in the movie "Big".
im still new at this but i just coded this in mysql and im not sure if i would have to join the tables beforehand or if they join from the SELECT QUERY BELOW:
*no values show in the table when i execute this queries
CREATE TABLE ACTOR(
ID INT,
FIRSTNAME VARCHAR(45),
LASTNAME VARCHAR(45)
);
INSERT INTO ACTOR (ID,FIRSTNAME,LASTNAME) VALUES (1, "TOM", "HANKS");
INSERT INTO ACTOR (ID,FIRSTNAME,LASTNAME) VALUES (2, "BILLY", "JOEL");
INSERT INTO ACTOR (ID,FIRSTNAME,LASTNAME) VALUES (3, "KEVIN", "HART");
CREATE TABLE MOVIEACTOR(
MOVIEID INT,
ACTORID INT
);
CREATE TABLE MOVIE(
ID INT,
TITLE VARCHAR(45),
GENRE VARCHAR(45)
);
INSERT INTO MOVIE (ID,TITLE,GENRE) VALUES (1, "ISLAND", "DRAMA");
INSERT INTO MOVIE (ID,TITLE,GENRE) VALUES (2, "BIG", "COMEDY");
SELECT ACTOR.FIRSTNAME FROM MOVIEACTOR JOIN ACTOR ON MOVIEACTOR.ACTORID WHERE MOVIEACTOR.MOVIEID=2
thank you for the help