Skip site navigation (1) Skip section navigation (2)

where clause question

From: Scott Frankel <leknarf(at)pacbell(dot)net>
To: PostgreSQL List <pgsql-general(at)postgresql(dot)org>
Subject: where clause question
Date: 2009-09-04 13:47:24
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-general

Is it possible to perform selects in a where clause of a statement?

Given a statement as follows:

     SELECT foo.foo_id,
     FROM foo, bar
     WHERE foo.bar_id = bar.bar_id
     AND = 'martini';

I'm looking for a way to recast it so that the select and from clauses  
refer to a single table and the join referencing the second table  
occurs in the where clause.  For example, something like this:

     SELECT foo.foo_id,
     FROM foo
     WHERE (SELECT * FROM foo, bar WHERE ...)
     foo.bar_id = bar.bar_id
     AND = 'martini';

I've explored the "where exists" clause, but it's not supported by the  
application toolkit I'm using.  AFAIK, I've only got access to where ...

Thanks in advance!


pgsql-general by date

Next:From: acordnerDate: 2009-09-04 14:17:40
Subject: Re: Add Large Object support to database programmatically
Previous:From: hubert depesz lubaczewskiDate: 2009-09-04 13:24:23
Subject: Re: strange error occurs when adding index

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group