[V4RB 0000496]: SQL-Problem

Sims, John AYU8 at CDC.GOV
Mon Feb 28 10:39:52 CST 2005


 -----Original Message-----
> From: valentina-beta-bounces at lists.macserve.net 
> [mailto:valentina-beta-bounces at lists.macserve.net] On Behalf 
> Of Claudius Sailer
> Sent: Monday, February 28, 2005 10:32 AM
> To: Valentina Beta
> Subject: Re: [V4RB 0000496]: SQL-Problem
> 
> 
> Hi Ruslan,
> 
> Am 27. Feb 2005 um 11:58 Uhr schrieb Ruslan Zasukhin:
> 
> > On 2/27/05 12:39 PM, "vbt at paradigma.ukrcom.kherson.ua" 
> > <vbt at paradigma.ukrcom.kherson.ua> wrote:
> >
> >> Summary:                    SQL-Problem
> >> Description:
> >> Following Code has result 0 records
> >>
> >> SELECT KO.Konto_Typ, KZ.Konto_Typ, B.Kategorie_ID, B.Betrag FROM
> >> Buchungen
> >> B, Konten KO, Konten KZ
> >> WHERE B.Herk_Konto=KO.RecID
> >> AND B.Ziel_Konto=KZ.RecID
> >> AND B.Deleted='0'
> >> AND B.BDatum<='27.02.2005'
> >>
> >> but it should have a lot
> >
> > Hi Claudius,
> >
> > I will recommend redo query using new SQL92 syntax of 
> joins. This make 
> > query more clean.
> >
> >
> > SELECT
> >     KO.Konto_Typ, KZ.Konto_Typ, B.Kategorie_ID, B.Betrag
> > FROM
> >     Buchungen B join Konten KO ON B.Herk_Konto=KO.RecID
> >                 join Konten KZ ON B.Ziel_Konto=KZ.RecID
> > WHERE
> >     B.Deleted='0' AND B.BDatum<='27.02.2005'
> 
> faster too?
> I don't know SQL92 syntax. I am a sybase hacker with learning 
> by seeing 
> and rebuilding ;-))
> The syntax you show me is a little bit confusing me.
> 
> How is it realized when I want to do following?
> 
> SELECT KO.Konto_Typ, KZ.Konto_Typ, B.Kategorie_ID, B.Betrag 
> FROM Buchungen B, Konten KO, Konten KZ WHERE 
> B.Herk_Konto=KO.RecID AND B.Ziel_Konto=KZ.RecID AND 
> KO.Konto_Type = 1 AND B.Deleted='0' AND B.BDatum<='27.02.2005'
> 
> is it then
> 
> SELECT
>      KO.Konto_Typ, KZ.Konto_Typ, B.Kategorie_ID, B.Betrag
> FROM
>      Buchungen B join Konten KO ON B.Herk_Konto=KO.RecID
>                  join Konten KZ ON B.Ziel_Konto=KZ.RecID
> WHERE KO.Konto_Type=1
> AND B.Deleted='0' AND B.BDatum<='27.02.2005'
> 
> in other words, when I have in restrictions something from joined 
> tables? where is this written?
> 
> bye
> 
> 
> Claudius

Hi Claudius,

If I am understanding your question correctly, you can do something like
this:
 
SELECT
     KO.Konto_Typ, KZ.Konto_Typ, B.Kategorie_ID, B.Betrag
FROM
      Buchungen B join Konten KO ON (B.Herk_Konto=KO.RecID AND
KO.Konto_Type=1)
                  join Konten KZ ON B.Ziel_Konto=KZ.RecID
WHERE B.Deleted='0' AND B.BDatum<='27.02.2005'

Both versions, this one and Ruslan's, will have the same results but
this one may "read" closer to how you are thinking.

Hope this helps.

-John


More information about the Valentina-beta mailing list