Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Substitutes for subqueries (subselects)?

Substitutes for subqueries (subselects)?

From: Kurta <submit_at_galleus.com>
Date: 2 Mar 2004 02:08:51 -0800
Message-ID: <efcb1994.0403020208.33ed38f@posting.google.com>


I have a SELECT query that uses subselects:

SELECT
  SAV_ID
FROM
  T_SVGS
WHERE
  (SAV_MEMB = 66470
OR
  SAV_CM_BASE IN (SELECT CMBS_ID FROM T_CM_BASEBASE AA WHERE CMBS_MEMB = 66470)
OR
  SAV_UM_BASE IN (SELECT UMBS_ID FROM T_UM_BASE BB WHERE UMBS_MEMB = 66470))

I'd have to return additional columns from the tables of the subqueries. I can achieve a desired result with joins and unions like this:

SELECT
  SAV_ID, SAV_MEMB, NULL CLASSTYPE
FROM
  T_SVGS
WHERE
  SAV_MEMB = 66470 UNION SELECT
  SAV_ID, SAV_CM_BASE, CMBS.CLASSTYPE
FROM
  T_SVGS, T_CM_BASEBASE CMBS
WHERE CMBS_ID = SAV_CM_BASE AND CMBS_MEMB = 66470 UNION SELECT
  SAV_ID, SAV_UM_BASE, UMBS.CLASSTYPE
FROM
  T_SVGS, T_UM_BASE UMBS
WHERE UMBS_ID = SAV_UM_BASE AND UMBS_MEMB = 66470 Is there a less harmful way to get the same results without having to rewrite all the queries?

Thanks for your help.

Kurta Received on Tue Mar 02 2004 - 04:08:51 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US