Re: Help with a subselect inside a view

Поиск
Список
Период
Сортировка
От Bill Moseley
Тема Re: Help with a subselect inside a view
Дата
Msg-id 20050825151925.GB14559@hank.org
обсуждение исходный текст
Ответ на Re: Help with a subselect inside a view  (Bruno Wolff III <bruno@wolff.to>)
Ответы Re: Help with a subselect inside a view  (Bruno Wolff III <bruno@wolff.to>)
Список pgsql-general
On Thu, Aug 25, 2005 at 08:05:36AM -0500, Bruno Wolff III wrote:
> On Wed, Aug 24, 2005 at 23:12:17 -0700,
>   Bill Moseley <moseley@hank.org> wrote:
> > I need a little SQL help:
> >
> > I'm trying to get a subselect working inside a view.
>
> Unfortunately you didn't show us what you tried. My guess would be that
> you didn't enclose the subselect in parenthesis.

No, it wasn't that.  I just didn't want to look too foolish. ;)

DROP VIEW cl;
CREATE VIEW cl  (id, instructor)
    AS
        SELECT class.id, person.first_name
          FROM class, instructors, person
         WHERE instructors.person = person.id
           AND class.id = (
                   SELECT instructors.id
                     FROM instructors, person
                    WHERE instructors.class = class.id
                      AND person.id = instructors.person
                    LIMIT 1
                );

Which returns a row for every row in "instructors" table.


> The distinct on solution that was suggested is probably a better way to
> go anyway.

Turns out it is, Thanks.


--
Bill Moseley
moseley@hank.org


В списке pgsql-general по дате отправления:

Предыдущее
От: "Julio Cesar"
Дата:
Сообщение: SOCKET Conection on Windwos 2003 vs PostgreSQL 8.0.1
Следующее
От: "Magnus Hagander"
Дата:
Сообщение: Re: SOCKET Conection on Windwos 2003 vs PostgreSQL 8.0.1