Re: exists - Mailing list pgsql-sql

From Joseph Shraibman
Subject Re: exists
Date
Msg-id 3B827D30.4030903@selectacast.net
Whole thread Raw
In response to Re: exists  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
Responses Re: exists
List pgsql-sql
Thank you, I was missing the parens.

If I do an explain I see:

->  Index Scan using m_u_and_p_key on m  (cost=0.00..3035.22 rows=1363 width=12)


even if I put a limit 1 on the select.  Why is that?

Stephan Szabo wrote:
> On Mon, 20 Aug 2001, Joseph Shraibman wrote:
> 
> 
>>I want to select a boolean if there exists a row in another table that matches this one. 
>>So I did select ..., (select count(*) from table2 where ...) > 0 ...
>>but that count(*) was taking forever.  I know there is a better way to do it, but whenever 
>>I try to use EXISTS I get a syntax error.  What is the proper way?
>>
> 
> Hmm, on current sources I can do:
> select ..., exists (select * from table2 where ...) from table1;
> 
> I don't know if that's new though...
> 


-- 
Joseph Shraibman
jks@selectacast.net
Increase signal to noise ratio.  http://www.targabot.com



pgsql-sql by date:

Previous
From: "Josh Berkus"
Date:
Subject: Re: Primary vs Unique Index
Next
From: "Jeff Eckermann"
Date:
Subject: Re: Getting 'n-1'th record.