Re: Problem with left join select command ??
"Robert Klemme" <[email protected]>
| Newsgroups | gmane.comp.db.maxdb |
|---|---|
| Message-ID | <[email protected]> |
2007/3/6, Beermann, Albert <[email protected]>: > I idea was to use the filter in the left join part of the select command and I hoped to get always all records from stpersonalstamm. Yeah, now I see it - I confused your time filters. Maybe Holger's solution will work. > Then I want to filter out all records with null values in the columns from lolohndaten. > > > If not, do you have any idea for my problem? Other than that it depends on what output you want. Here's probably another solution that works. select * from stpersonalstamm left join ( select * from lolohnkopf where lolohnkopf.lofuerjahr = ?l_jj and lolohnkopf.lofuermonat = ?l_mm) lolohnkopf on stpersonalstamm.stpersonalstammid = lolohnkopf.stpersonalstammid left join lolohndaten on lolohndaten.lolohnkopfid = lolohnkopf.lolohnkopfid where stpersonalstamm.stnlstammid = ?P_stnlstammid and stpersonalstamm.staustritt >= ?l_aktdatum and stpersonalstamm.steintrittnl <= ?l_lastdatum order by stpersonalstamm.stpersonalstammid i.e. use an inline view that selects only the records you need / want based on year and month. HTH robert > I need all records from stpersonalstamm that have no records in lolohndaten for a given period. The period is only in lolohnkopf! > So I have to search from stpersonalstamm into lolohnkopf into lolohndaten ! > > Any help welcomed > > Mit freundlichen Grüssen > Albert Beermann > Piepenbrock Service GmbH & Co. KG > Hannoversche Straße 91-95 > 49084 Osnabrück > Tel: + 49 (0) 5 41/ 58 41-868 > Fax: + 49 (0) 5 41/ 58 41-869 > mailto:[email protected] > Der Inhalt dieser E-Mail ist vertraulich. Falls Sie nicht der angegebene Empfänger sind oder falls diese E-Mail irrtümlich an Sie adressiert wurde, verständigen Sie bitte den Absender sofort und löschen Sie die E-Mail sodann. Das unerlaubte Kopieren sowie die unbefugte Übermittlung sind nicht gestattet. Die Sicherheit von Übermittlungen per E-Mail kann nicht garantiert werden. Falls Sie eine Bestätigung wünschen, fordern Sie bitte den Inhalt der E-Mail als Hardcopy an. > > > > -----Ursprüngliche Nachricht----- > > Von: Robert Klemme [mailto:[email protected]] > > Gesendet: Dienstag, 6. März 2007 14:19 > > An: Beermann, Albert > > Cc: [email protected] > > Betreff: Re: Problem with left join select command ?? > > > > 2007/3/6, Beermann, Albert <[email protected]>: > > > Hello Everybody > > > > > > > > > > > > Left join problem with maxdb 7.6.00.25 (64 bit on suse linux) > > > > > > > > > > > > I have 3 tables stpersonalstamm,lolohnkopf,lolohndaten > > > > > > The link between stpersonalstamm and lolohnkopf is stpersonalstammid > > > > > > The link between lolohnkopf and lolohndaten is lolohnkopfid > > > > > > > > > > > > > > > > > > In lolohnkopf there can be 1 to n records for a stpersonalstammid for a > > > given lofuerjahr,lofuermonat but don't have to > > > > > > In lolohndaten there can be 1 to n records for a lolohnkopfid but don't > > > have to > > > > > > > > > > > > I want to search all records from stpersonalstamm and find out wether > > > they have entries in lolohnkopf and in lolohndaten or not > > > > > > > > > > > > select * from stpersonalstamm > > > > > > left join lolohnkopf on stpersonalstamm.stpersonalstammid = > > > lolohnkopf.stpersonalstammid > > > > > > and lolohnkopf.lofuerjahr = ?l_jj and lolohnkopf.lofuermonat = ?l_mm > > > > > > left join lolohndaten on lolohndaten.lolohnkopfid = > > > lolohnkopf.lolohnkopfid > > > > > > where stpersonalstamm.stnlstammid = ?P_stnlstammid > > > > > > and stpersonalstamm.staustritt >= ?l_aktdatum > > > > > > and stpersonalstamm.steintrittnl <= ?l_lastdatum > > > > > > order by stpersonalstamm.stpersonalstammid " > > > > > > > > > > > > I expected a result cursor with all columns from stpersonalstamm , > > > > > > all columns from lolohnkopf (filled or null) and all columns from > > > lolohndaten (filled or null) > > > > > > > > > > > > If there are some records in lohnkopf for a given lofuermonat,lofuerjahr > > > the select works as expected. > > > > > > The lolohnkopf part of the result cursor is filled with correct data or > > > null values > > > > > > > > > > > > But if there are no records in lolohnkopf for a given > > > lofuermonat,lofuerjahr the result cursor is empty ??????????? > > > > What do you expect? You use "and lolohnkopf.lofuerjahr = ?l_jj and > > lolohnkopf.lofuermonat = ?l_mm" as a filter - if no data matches you > > get an empty result. That's the way SQL works. > > > > Regards > > > > robert > > > > -- > > Have a look: http://www.flickr.com/photos/fussel-foto/ > -- Have a look: http://www.flickr.com/photos/fussel-foto/ -- MaxDB Discussion Mailing List For list archives: http://lists.mysql.com/maxdb To unsubscribe: http://lists.mysql.com/[email protected]