phpbar.de logo

Mailinglisten-Archive

Kaskadierte join's

Kaskadierte join's

Wolfgang Hauck mysql-de_(at)_lists.bttr.org
Thu, 24 Oct 2002 14:53:55 +0200


>hallo,

>tm.KNR ist eindeutig
>t1.KNR ist nicht eindeutig
>t2.KNR ist nicht eindeutig

>tm besitzt KNR, die in t1 und/oder t2 nicht enthalten sind,
>die aber in der result tabelle erscheinen sollen?

>versuch es mal damit:

>SELECT
>      KUNDENUMMER, s1 + s3 , summe_2
>FROM
>       ( select KUNDENNUMMER from table_master ) as tm
> LEFT JOIN
>      ( select f01, sum( f07 ) as s1 from table_1 group by f01 ) as t1
>    ON tm.KUNDENNUMMER = t1.f01
> LEFT JOIN
>      ( select f00, sum( f03 ) as summe_2, sum( f05 ) as s3 from table_2
>group by f00 ) as t2
>    ON tm.KUNDENNUMMER = t2.f00

Hi michael,

MySQL Server currently only supports nested queries of the form INSERT ... 
SELECT ... and REPLACE ... SELECT .... You can, however, use the function 
IN() in other contexts. Subselects are currently being implemented in the 
4.1 development tree.

For more complicated subqueries you can often create temporary tables to 
hold the subquery. In some cases, however, this option will not work. The 
most frequently encountered of these cases arises with DELETE statements, 
for which standard SQL does not support joins (except in subselects).

MFG Wolfgang

-- 
Infos zur Mailingliste, zur Teilnahme und zum An- und Abmelden unter
-->>  http://www.4t2.com/mysql 



php::bar PHP Wiki   -   Listenarchive