On Sat, 10 Oct 2009, [utf-8] Dag-Erling Sm??rgrav wrote:
> Stephan Szabo writes:
> > Not at all tested as I don't have access to my db right now, but I think
> > something like one of these would work:
> >
> > select fs.film.title, fs.film.year
> > from fs.film
> > where exists(select 1 from f
Stephan Szabo writes:
> Not at all tested as I don't have access to my db right now, but I think
> something like one of these would work:
>
> select fs.film.title, fs.film.year
> from fs.film
> where exists(select 1 from fs.star where fs.film.id = fs.star.film
> and fs.star.last = 'Sheen');
Richard Albright writes:
> you could use distinct on
>
> select distinct on (fs.film.title, fs.film.year ) title, year
> from fs.film left join fs.star on fs.film.id = fs.star.film
> where fs.star.last = 'Sheen';
Thanks, I didn't know about "distinct on". This version uses the
primary (surroga
you could use distinct on
select distinct on (fs.film.title, fs.film.year ) title, year
from fs.film left join fs.star on fs.film.id = fs.star.film
where fs.star.last = 'Sheen';
On Sat, 2009-10-10 at 00:53 +0200, Dag-Erling Smørgrav wrote:
> Consider the attached schema (filmstars.sql), which i
On Sat, 10 Oct 2009, [utf-8] Dag-Erling Sm??rgrav wrote:
> Consider the attached schema (filmstars.sql), which is a poorly designed
> database of films and actors. The following query gives me a list of
> films in which either Charlie or Martin Sheen starred:
>
> select fs.film.title, fs.film.yea
Consider the attached schema (filmstars.sql), which is a poorly designed
database of films and actors. The following query gives me a list of
films in which either Charlie or Martin Sheen starred:
select fs.film.title, fs.film.year
from fs.film left join fs.star on fs.film.id = fs.star.film
w