Re: Subquery problem

From: (wrong string) لل <jjvainio_at_cc.hut.fi>
Date: Mon, 22 Jan 2001 02:01:30 +0200
Message-ID: <3A6B785A.F4C81134_at_cc.hut.fi>


Thanks! Your message was quite helpful.

> Your solution, even if it worked, would not show those movies where no
> users had given it a rating of 5. This may or may not be a requirement
> but is worth pointing out.

Yes, that was in fact a requirement (and a fault in my first 'solution').

> An ANSII-92 standard SQL solution:
> LEFT OUTER JOIN ratings

This one did not work, because psql doesn't support outer joins (yet).

> This works in SQL Server and is more intuitive:
> SELECT movies.name,
> movies.length,
> fives = (
> SELECT COUNT(*)
> FROM ratings
> WHERE ratings.name = movies.name
> AND ratings.rating = '5'
> )
> FROM movies

But then again this one does work, after changing fives=() into () as fives. It turns out that psql 7.0 supports subselects in all the other places except FROM. Now I'm embarrassed that I didn't think of this myself... Received on Mon Jan 22 2001 - 01:01:30 CET

Original text of this message