Re: exists

From: Joseph Shraibman <jks(at)selectacast(dot)net>
To: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
Cc: pgsql-sql <pgsql-sql(at)postgresql(dot)org>
Subject: Re: exists
Date: 2001-08-21 15:24:32
Message-ID: 3B827D30.4030903@selectacast.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)selectacast(dot)net
Increase signal to noise ratio. http://www.targabot.com

In response to

  • Re: exists at 2001-08-21 05:40:54 from Stephan Szabo

Responses

  • Re: exists at 2001-08-21 16:45:25 from Stephan Szabo

Browse pgsql-sql by date

  From Date Subject
Next Message Albert REINER 2001-08-21 16:23:16 Re: How to execute a system file in procedure?
Previous Message Josh Berkus 2001-08-21 15:15:31 Re: Getting 'n-1'th record.