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 -> Re: Multiple selects

Re: Multiple selects

From: Harald Maier <maierh_at_myself.com>
Date: Fri, 05 Sep 2003 05:12:35 +0200
Message-ID: <m3r82wszbw.fsf@ate.maierh>


Leigh Riley <dontEmailMeDirectly_at_home.org> writes:

> Hi there,
>
> I'm new to the world of Oracle, so maybe someone out there can offer
> some suggestions here:
>
> I currently execute 3 SQL statement like this in my Java class:
> ------------------------------------
> SELECT count(*) as count FROM myTable
> where this="that" and that = "the other";
>
> SELECT count(*) as count FROM myTable
> where this="this" and that = "that";
>
> SELECT count(*) as count FROM myTable
> where this="confusing";
> ------------------------------------
> I am wondering if it's possible to execute these 3 SQL statement with
> one query and get a resultSet of e.g. 3,3,3?

You can use the union keyword:

,----

| SELECT count(*) as count FROM myTable
| where this="that" and that = "the other"
| union
| SELECT count(*) as count FROM myTable
| where this="this" and that = "that"
| union
| SELECT count(*) as count FROM myTable
| where this="confusing";

`----

Harald Received on Thu Sep 04 2003 - 22:12:35 CDT

Original text of this message

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