Skip site navigation (1) Skip section navigation (2)

How do you do a subselect in postgresql?

From: Mel Roman <f24012(at)yahoo(dot)com>
To: Postgresql Novice_Mailing_List <pgsql-novice(at)postgresql(dot)org>
Subject: How do you do a subselect in postgresql?
Date: 2002-01-11 04:52:10
Message-ID: 20020111045210.37541.qmail@web9602.mail.yahoo.com (view raw or flat)
Thread:
Lists: pgsql-novice
Hello:

I've been working with databases for several years now
(primarily MS SQL Server) and have recently started
working with Postgresql on a trial basis.  I can't
seem to get subqueries to work in postgresql.  For
example, below is a simple dump of my table weather:

meltest=> select * from weather;

     city      | temp_lo | temp_hi |    date    
---------------+---------+---------+------------
 San Francisco |      46 |      50 | 1994-11-27
 Los Angelos   |      49 |      55 | 1994-11-28
(2 rows)

If I try to do a subselect as follows, I get a parsing
error:

meltest=>select * from (select * from weather) as w;
ERROR:  parser: parse error at or near "select"

I don't see anything wrong with the SQL syntax, even
after comparing it against the on-line documentation. 
Can someone please point out what's wrong with this
syntax?  I know it works on MS SQL Server - do you
have to do it differently in Postgresql?

Any help would be appreciated.

Thanks,

Mel Roman




__________________________________________________
Do You Yahoo!?
Send FREE video emails in Yahoo! Mail!
http://promo.yahoo.com/videomail/

Responses

pgsql-novice by date

Next:From: Tom LaneDate: 2002-01-11 05:11:23
Subject: Re: How do you do a subselect in postgresql?
Previous:From: Sharon CowlingDate: 2002-01-11 03:14:00
Subject: Table with default value

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group