>I am  to list the film title and the leading actor for all of the films
>'Julie Andrews' played in. 

>The following is structure of the tables used:

>movie(id, title, yr, director, budget, gross);
>actor(id, name);
>casting(movieid, actorid, ord). 
>The column name ord has a value of 1 if the actor is in starring role.

Translate the English in parts:

"all the films "Julie Andrews" olayed in
->
select movie.id
  from movie, casting, actor
 where movie.id = casting.movieid
   and casting.actorid = actor.id
   and actor.name = 'Julie Andrews'

then wrap the part "list the film title and the leading actor" around that list 
of films:

select movie.name, actor.name
  from movie, casting, actor
 where movie.id = casting.movieid
   and casting.actorid = actor.id
   and casting.org = 1
   and movie.id in (select movie.id
                      from movie, casting, actor
                     where movie.id = casting.movieid
                       and casting.actorid = actor.id
                       and actor.name = 'Julie Andrews');

Being able to translate problem statements from well formed human language into 
well formed computer language statement(s) "The Solution" is what separates 
"programmers" from "coders".  The problem statement does not require any 
ordering of the results, so they are in visitation order (which is not random, 
but may appear to be random to "coders").





_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to