Board index » delphi » SQL-Statement with two LEFT OUTER JOINs

SQL-Statement with two LEFT OUTER JOINs

Hello!

What is the correct local SQL-statement if I want two left outer
joins. My sql command now is like this:
   Select
     Anreden.Anrede, Adressen.Name,  Adressen.Kontakt
   From adressen
   LEFT OUTER JOIN Anreden ON Adressen.IDAnrede = Anreden.ID
   where Name like :pBuchst

Now I want a second left outer join:  The following graphic should
explain it:

///////////////////////                     //////////////////////////
///  Anreden  /// 1----------n ///                    ///
///////////////////////                     ///                    ///
                                            ///  Adressen   ///
///////////////////////                     ///                    ///
///   Post       /// 1----------n ///                    ///
///////////////////////                     //////////////////////////

Thanks for any suggestions.
Emmerich

Please E-mail it to me, too
_________________________________________________
Emmerich Kitzler
University of Technology, Vienna, Austria

"We live in a world where a fool makes many fools
 but a wise man only a few wise man."

"Wir leben in einer Welt,
 worin ein Narr viele Narren,
 aber ein weiser Mann
 nur wenige Weise macht."
 (Immanuel Kant)

 

Re:SQL-Statement with two LEFT OUTER JOINs


Emmerich,

The following syntax performs a second left outer join using the
ANSI 92 making use of tables in the Employee.gdb InterBase
database file:

SELECT *
FROM (EMPLOYEE E LEFT OUTER JOIN EMPLOYEE_PROJECT EP
  ON E.EMP_NO = EP.EMP_NO)
  LEFT OUTER JOIN DEPARTMENT D
    ON E.DEPT_NO = D.DEPT_NO

Hope this helps!

Paul Powers

Re:SQL-Statement with two LEFT OUTER JOINs


Hello Paul!

Your SQL-statement works fine if I connect to the InterBase DB. But I
have Paradox tables and want to query them with a TQuery object. I
typed the command into the SQL-property of the TQuery object. When I
set active TRUE, an error message occurs saying "Feature not
available!" (I hope, I've translated the message correctly. In German
it is "Merkmal nicht verfuegbar!"). If I try the same with only one
outer join, it works fine.
Does TQuery not support the SQL-92 standard???

Thanks to anyone, who knows the answer or solution.

Emmerich

Quote
70007.4620 <70007.4...@CompuServe.COM> wrote:
>Emmerich,
>The following syntax performs a second left outer join using the
>ANSI 92 making use of tables in the Employee.gdb InterBase
>database file:
>SELECT *
>FROM (EMPLOYEE E LEFT OUTER JOIN EMPLOYEE_PROJECT EP
>  ON E.EMP_NO = EP.EMP_NO)
>  LEFT OUTER JOIN DEPARTMENT D
>    ON E.DEPT_NO = D.DEPT_NO
>Hope this helps!
>Paul Powers

_________________________________________________
Emmerich Kitzler
University of Technology, Vienna, Austria

"We live in a world where a fool makes many fools
 but a wise man only a few wise man."

"Wir leben in einer Welt,
 worin ein Narr viele Narren,
 aber ein weiser Mann
 nur wenige Weise macht."
 (Immanuel Kant)

Re:SQL-Statement with two LEFT OUTER JOINs


Quote
Emmerich wrote:

> Hello Paul!

> Your SQL-statement works fine if I connect to the InterBase DB. But I
> have Paradox tables and want to query them with a TQuery object. I
> typed the command into the SQL-property of the TQuery object. When I
> set active TRUE, an error message occurs saying "Feature not
> available!" (I hope, I've translated the message correctly. In German
> it is "Merkmal nicht verfuegbar!"). If I try the same with only one
> outer join, it works fine.
> Does TQuery not support the SQL-92 standard???

> Thanks to anyone, who knows the answer or solution.

> Emmerich

> 70007.4620 <70007.4...@CompuServe.COM> wrote:
> >Emmerich,

> >The following syntax performs a second left outer join using the
> >ANSI 92 making use of tables in the Employee.gdb InterBase
> >database file:

> >SELECT *
> >FROM (EMPLOYEE E LEFT OUTER JOIN EMPLOYEE_PROJECT EP
> >  ON E.EMP_NO = EP.EMP_NO)
> >  LEFT OUTER JOIN DEPARTMENT D
> >    ON E.DEPT_NO = D.DEPT_NO

> >Hope this helps!

> >Paul Powers

Emmerich,

try:
SELECT *
FROM EMPLOYEE E LEFT OUTER JOIN EMPLOYEE_PROJECT EP ON E.EMP_NO = EP.EMP_NO,
     EMPLOYEE E LEFT OUTER JOIN DEPARTMENT D ON E.DEPT_NO = D.DEPT_NO
that should work...

Bye
Michael Btepage

Other Threads