newbie sql question re: subqueries, order by, and limit

From: Thomas Stepleton <tom(at)cs(dot)swarthmore(dot)edu>
To: pgsql-novice(at)postgresql(dot)org
Subject: newbie sql question re: subqueries, order by, and limit
Date: 2000-12-27 23:38:11
Message-ID: Pine.GSO.4.10.10012271829410.5358-100000@allspice.cs.swarthmore.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hello all:

Witness my latest SQL trainwreck:

SELECT uid, title FROM temptbl WHERE msgid NOT IN ( SELECT msgid FROM
temptbl ORDER BY msgid DESC LIMIT 50 );

temptbl contains the data for a simple messageboard. The idea for this
query is to get all entries in tmptbl except the 50 newest ones (msgid
autoincrements). There's no special point to this excercise; it's just
something I thougt I'd try.

Problem is, in the psql shell, I get this reply:

ERROR: parser: parse error at or near "order"

Why is this happening? How can I fix it? Once again, I get the feeling
that I'm doing this the Wrong Way. What would be the Right Way to take
care of this task?

Thanks a lot,
--Tom

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Karla Peralta 2000-12-28 17:02:24 Re: Transactions
Previous Message James Clawson 2000-12-27 20:10:28 user not in pg_shadow