sql - Postgresql many to many select -


i have 2 tables this:

movie table

movieid | title | actorid 

actor table

actorid | name 

i want return actors name of 1 movie if 1 of them instance equal 'johnny depp'

any on correct way go appreciated.

i want return actors name of 1 movie if 1 of them instance equal 'johnny depp'

this confusing. either (a) want movies given actor; or (b) want actors given movie.

i agree @realcheeselord here, because isn't complex problem, feeling magnanimous morning:

(a)

select * movie m      left join actor on m.actorid = a.actorid a.name = 'johnny depp'; 

(b)

select * actor     left join movie on a.actorid = m.actorid m.title = 'edward scissorhands'; 

edit: re-reading confusing question, seems interpreted as: want actors in movies 'johnny depp' actor in...

(c)

select * actor     left join movie m on a.actorid = m.actorid m.movieid in (     select mm.movieid movie mm          left join actor aa on mm.actorid = aa.actorid      aa.name = 'johnny depp' );      

Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -