pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Achilleus Mantzios <achill@matrix.gatewaynet.com>
To: Wei Weng <wweng@kencast.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: How do you write this query?
Date: Fri, 1 Nov 2002 09:51:04 +0200 (EET)
Message-ID: <Pine.LNX.4.44.0211010949000.3526-100000@matrix.gatewaynet.com> (raw)
In-Reply-To: <1036088486.13986.19.camel@Monet>

On 31 Oct 2002, Wei Weng wrote:

and yet another equivalent query:

SELECT f1.data1 from test f1,test f2 where f1.data=3 and f1.data2 =
f2.data2 and f2.data1='pooh';

> I have a table
>
>                  Table "test"
> Column	|            Type        | Modifiers
> --------+------------------------+----------
> data    | integer                | not null
> data1   | character varying(128) | not null
> data2   | character varying(128) | not null
>
> (Note: data is NOT the primary key.)
>
> And
> select * from test
> returns
>
>
>  data | data1 | data2
> ------+-------+-------
>     1 | foo   | bar
>     2 | greg  | bar
>     3 | pooh  | bar
>     4 | dah   | peng
>
> I need a query that returns me the "data1" that satisfies the logic of
> the following pseudo code:
>
> 1: select data2 into @out from test where data1 = 'pooh'
> 2: select data1 from test where data2 = @out and data = 3
>
>
> What do I do?
>
> Thanks!
>
> --
> Wei Weng
> Network Software Engineer
> KenCast Inc.
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo@postgresql.org so that your
> message can get through to the mailing list cleanly
>

==================================================================
Achilleus Mantzios
S/W Engineer
IT dept
Dynacom Tankers Mngmt
Nikis 4, Glyfada
Athens 16610
Greece
tel:    +30-10-8981112
fax:    +30-10-8981877
email:  achill@matrix.gatewaynet.com
        mantzios@softlab.ece.ntua.gr




view thread (4+ messages)

Message-ID: <Pine.LNX.4.44.0211010949000.3526-100000@matrix.gatewaynet.com>
Permalink:  ../Pine.LNX.4.44.0211010949000.3526-100000@matrix.gatewaynet.com/
Also on:    postgresql.org/message-id/Pine.LNX.4.44.0211010949000.3526-100000@matrix.gatewaynet.com

 · 

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: achill@matrix.gatewaynet.com, wweng@kencast.com
  Subject: Re: How do you write this query?
  In-Reply-To: <Pine.LNX.4.44.0211010949000.3526-100000@matrix.gatewaynet.com>

* 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