pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Joseph Shraibman <jks@selectacast.net>
To: Stephan Szabo <sszabo@megazone23.bigpanda.com>
Cc: pgsql-sql <pgsql-sql@postgresql.org>
Subject: Re: exists
Date: Tue, 21 Aug 2001 11:24:32 -0400
Message-ID: <3B827D30.4030903@selectacast.net> (raw)
References: <Pine.BSF.4.21.0108202239210.3144-100000@megazone23.bigpanda.com>

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




view thread (13+ messages)  latest in thread

Message-ID: <3B827D30.4030903@selectacast.net>
Permalink:  ../3B827D30.4030903@selectacast.net/
Also on:    postgresql.org/message-id/3B827D30.4030903@selectacast.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: jks@selectacast.net, sszabo@megazone23.bigpanda.com
  Subject: Re: exists
  In-Reply-To: <3B827D30.4030903@selectacast.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox