Обсуждение: [GENERAL] Set operator.

Поиск
Список
Период
Сортировка

[GENERAL] Set operator.

От
Stuart Rison
Дата:
Dear all,

What set operators other then UNION do PG have?

In particular, I am interested in the MINUS or equivalent operator. e.g

table1:

value1
1
2
3
4
5
6
7
8
9

table2:

value2
1
3
5
7
9

SELECT table1.value1 FROM table1 MINUS table2.value2 FROM table2;

result:
2
4
6
8

I have PG 6.4.0 so please specify what version of PG might have this
functionality... also, can anybody offer hints as to how to implement such
functionality if necessary?

Regards,

Stuart.

+-------------------------+--------------------------------------+
| Stuart Rison            | Ludwig Institute for Cancer Research |
+-------------------------+ 91 Riding House Street               |
| Tel. (0171) 878 4041    | London, W1P 8BT, UNITED KINGDOM.     |
| Fax. (0171) 878 4040    | stuart@ludwig.ucl.ac.uk              |
+-------------------------+--------------------------------------+

Re: [GENERAL] Set operator.

От
"Nikolay Mijaylov"
Дата:
I know it is not the same but try this:


select table1.value1 from table1 where table1.value1 not in (select
table2.value2 from table2)


well im never try this to this moment..... :)
but u can

nmmm.hypermart.net
w3.nsi.bg/linux
www.nsi.bg/nmmm



----- Original Message -----
From: Stuart Rison <stuart@ludwig.ucl.ac.uk>
To: <pgsql-general@postgreSQL.org>
Sent: 13 Þëè 1999 ã. 13:18
Subject: [GENERAL] Set operator.


> Dear all,
>
> What set operators other then UNION do PG have?
>
> In particular, I am interested in the MINUS or equivalent operator. e.g
>
> table1:
>
> value1
> 1
> 2
> 3
> 4
> 5
> 6
> 7
> 8
> 9
>
> table2:
>
> value2
> 1
> 3
> 5
> 7
> 9
>
> SELECT table1.value1 FROM table1 MINUS table2.value2 FROM table2;
>
> result:
> 2
> 4
> 6
> 8
>
> I have PG 6.4.0 so please specify what version of PG might have this
> functionality... also, can anybody offer hints as to how to implement such
> functionality if necessary?
>
> Regards,
>
> Stuart.
>
> +-------------------------+--------------------------------------+
> | Stuart Rison            | Ludwig Institute for Cancer Research |
> +-------------------------+ 91 Riding House Street               |
> | Tel. (0171) 878 4041    | London, W1P 8BT, UNITED KINGDOM.     |
> | Fax. (0171) 878 4040    | stuart@ludwig.ucl.ac.uk              |
> +-------------------------+--------------------------------------+


Re: [GENERAL] Set operator.

От
Bruce Momjian
Дата:
6.5 has INTERSECT and EXCEPT.

> Dear all,
>
> What set operators other then UNION do PG have?
>
> In particular, I am interested in the MINUS or equivalent operator. e.g
>
> table1:
>
> value1
> 1
> 2
> 3
> 4
> 5
> 6
> 7
> 8
> 9
>
> table2:
>
> value2
> 1
> 3
> 5
> 7
> 9
>
> SELECT table1.value1 FROM table1 MINUS table2.value2 FROM table2;
>
> result:
> 2
> 4
> 6
> 8
>
> I have PG 6.4.0 so please specify what version of PG might have this
> functionality... also, can anybody offer hints as to how to implement such
> functionality if necessary?
>
> Regards,
>
> Stuart.
>
> +-------------------------+--------------------------------------+
> | Stuart Rison            | Ludwig Institute for Cancer Research |
> +-------------------------+ 91 Riding House Street               |
> | Tel. (0171) 878 4041    | London, W1P 8BT, UNITED KINGDOM.     |
> | Fax. (0171) 878 4040    | stuart@ludwig.ucl.ac.uk              |
> +-------------------------+--------------------------------------+
>
>


--
  Bruce Momjian                        |  http://www.op.net/~candle
  maillist@candle.pha.pa.us            |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

RE: [GENERAL] Set operator.

От
"Jackson, DeJuan"
Дата:
Try EXCEPT (only in v6.5).
    -DEJ

> -----Original Message-----
> From:    Nikolay Mijaylov [SMTP:nmmm@nsi.bg]
> Sent:    Tuesday, July 13, 1999 6:41 AM
> To:    pgsql-general@postgreSQL.org
> Subject:    Re: [GENERAL] Set operator.
>
> I know it is not the same but try this:
>
>
> select table1.value1 from table1 where table1.value1 not in (select
> table2.value2 from table2)
>
>
> well im never try this to this moment..... :)
> but u can
>
> nmmm.hypermart.net
> w3.nsi.bg/linux
> www.nsi.bg/nmmm
>
>
>
> ----- Original Message -----
> From: Stuart Rison <stuart@ludwig.ucl.ac.uk>
> To: <pgsql-general@postgreSQL.org>
> Sent: 13 Þëè 1999 ã. 13:18
> Subject: [GENERAL] Set operator.
>
>
> > Dear all,
> >
> > What set operators other then UNION do PG have?
> >
> > In particular, I am interested in the MINUS or equivalent operator. e.g
> >
> > table1:
> >
> > value1
> > 1
> > 2
> > 3
> > 4
> > 5
> > 6
> > 7
> > 8
> > 9
> >
> > table2:
> >
> > value2
> > 1
> > 3
> > 5
> > 7
> > 9
> >
> > SELECT table1.value1 FROM table1 MINUS table2.value2 FROM table2;
> >
> > result:
> > 2
> > 4
> > 6
> > 8
> >
> > I have PG 6.4.0 so please specify what version of PG might have this
> > functionality... also, can anybody offer hints as to how to implement
> such
> > functionality if necessary?
> >
> > Regards,
> >
> > Stuart.
> >
> > +-------------------------+--------------------------------------+
> > | Stuart Rison            | Ludwig Institute for Cancer Research |
> > +-------------------------+ 91 Riding House Street               |
> > | Tel. (0171) 878 4041    | London, W1P 8BT, UNITED KINGDOM.     |
> > | Fax. (0171) 878 4040    | stuart@ludwig.ucl.ac.uk              |
> > +-------------------------+--------------------------------------+
>