From: Sherwin Daganato <win@email.com.ph>
To: pgsql-sql@postgresql.org
Subject: better way
Date: Mon, 28 Aug 2000 19:13:27 +0800
Message-ID: <fc.000f567200676588000f567200676588.6768b1@fc.emc.com.ph> (raw)
Is there a better way to write this:
SELECT a.oid_fld FROM for_payment a
WHERE a.serial_fld <> 2
AND EXISTS
(SELECT b.char_fld FROM for_payment b
WHERE b.serial_fld = 2
AND b.char_fld = a.char_fld)
Table for_payment
+-------------+------------+-----------+
| serial_fld | char_fld | oid_fld |
+-------------+------------+-----------+
| 1 | test1 | 456701 |
| 2 | test1 | 456702 |
| 3 | test1 | 456703 |
| 4 | test2 | 456704 |
| 5 | test3 | 456705 |
+-------------+------------+-----------+
sample problem:
Assuming that I pick 2 in serial_fld.
How do I get the oid_fld of the rows with char_fld equal
to the char_fld of 2?
I should get these:
+-----------+
| oid_fld |
+-----------+
| 456701 |
| 456702 |
+-----------+
Thanks.
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: win@email.com.ph
Subject: Re: better way
In-Reply-To: <fc.000f567200676588000f567200676588.6768b1@fc.emc.com.ph>
References: <fc.000f567200676588000f567200676588.6768b1@fc.emc.com.ph>
* 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