Subject AW: [firebird-support] Difficult condiion question
Author checkmail

Set, many thanks for your kind support :)

 

Von: firebird-support@yahoogroups.com [mailto:firebird-support@yahoogroups.com]
Gesendet: Donnerstag, 28. August 2014 15:33
An: firebird-support@yahoogroups.com
Betreff: RE: [firebird-support] Difficult condiion question

 

 

>I think I have it:

>
>SELECT TT.TEILENR, TT.BEZEICHNUNG, LS.MENGE, TT.MINB, LS.TYP, TT.TYP
>FROM TTEILE TT
>LEFT JOIN TLAGER_SUM LS
>ON TT.TEILENR = LS.TEILENR
>AND LS.TYP = 1
>
>WHERE TT.TYP=1
>AND (LS.MENGE IS NOT NULL
>AND LS.MENGE<tt.minb
>OR TT.MINB>0 and ls.menge is null)
>ORDER BY TT.TEILENR;
>
>The and ls.typ = 1 should exclude all records from tlager_-sum there not typ 1? It was fine!!!!! Thank you
>
>Can you tell me what about the statements before the where conditions? Until now I don't know about.

>Your syntax returns me too many records, some of them has entries in the table tlager_sum, but the amount and the present typ (1) returns me this statement, it is null.

Good to hear that you figured it out, Olaf. Sorry for misleading you and writing code that returned records if TT.MINB > 0 regardless of ls.menge. You can still reduce your query by one line if you want, LS.MENGE IS NOT NULL can simply be removed.

The statements before the WHERE condition are part of the LEFT JOIN. Typically, that's where you put criteria relating to the right table. If you write such criteria in the WHERE clause, they could (logically speaking) turn the LEFT JOIN into an INNER JOIN.

Set