Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Mysql first look value and then search with value find

So I have two tables :

Film :

id | title | year | Director

Casting :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

id | title | year | actors 

So What I am trying to do is to find all the actors that have the same title as the director.

So what I am trying to do first is

This will return me the film name.
And with the film name I want to do a second research to find all the actors that are in that film

So first :

Select title WHERE Director="name"

THEN Select Actor WHERE title="The first value I am looking for"

One example I am looking for Starwars movie.

My table information :

FILM

id:0 | title: "Starwars" | productor : "George Lucas"

Casting:

id:0 | title: "Starwars" | Acteur : "Ewan McGregor"

id:1 | title: "Starwars" | Acteur : "Natalie Portman"

So my MySQL should return only the name actors

Acteur : "Ewan McGregor", "Natalie Portman"

Thanks a lot of your help!

>Solution :

You can do it using simple query as :

SELECT GROUP_CONCAT(Casting.actors SEPARATOR ', ')
FROM Film
JOIN Casting ON Film.title = Casting.title
WHERE Film.Director = 'director_name'
AND Film.title = 'film_title';      
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading