limit with subselect

From: "A B" <gentosaker(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: limit with subselect
Date: 2008-07-25 10:02:23
Message-ID: dbbf25900807250302u407e49d2t42d29f8dc37a4ff6@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Sorry if this is a double posting, I think the previous message was lost.

I have two tables
T (
id int primary key,
a int,
b int
)

T2 (
id int references T,
c int
);

and I wish to get 20 lines from T like this

select id,a,b from T where id not in (select id from T2 where c=5) limit 20;

but that does not seem to work. How can I get what I want? What 20
records are selected is not important. I just need 20.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message A. Kretschmer 2008-07-25 10:22:10 Re: limit with subselect
Previous Message A B 2008-07-25 09:52:56 Subselect with limit