Use Left Outer join vis

from Table1 T1 left outer join Table2 T2 on T2.T2ID = T1.T1ID

Gives all the records in T1 regardless if there is a matching record in T2.
Columns selected from T2 will have a null value.
-----Original Message-----
From: Mark Derricutt <[EMAIL PROTECTED]>
To: Multiple recipients of list delphi <[EMAIL PROTECTED]>
Date: Thursday, 1 July 1999 14:09
Subject: [DUG]: SQL Joins...


A question on joins which I'm again lost on :P

I have a query that returns x amount of rows (query 1 below).  The problem
I have is that CalcMethod defines several Attribute/Method pairs for an
Object, some of which may, and may not appear in the ScreenAttr table.

As it stands, the query only returns the records that appear in both
ScreenAttr -and- CalcMethod, however what I -really- want is all
Attribute/Methods from CalcMethod, and those that don't appear in
ScreenAttr to have null fields for X and Y, and those that do, to have
their values.

I think I need to use a union, or some form of join, but I'm not sure.
(This is probably really badly explain so I hope someone understands this).

Mark


Query 1:

SELECT DISTINCT
  D.Object, D.CalcTable, D1.X, D1.Y, d3.Attribute, d3.Method
FROM
  Objects D, ScreenAttr D1, CalcMethod d3
WHERE
  (d.Object = d3.Object) AND
  (d.Object = :Object) AND
  (d.Object = d1.Object) AND
  (d1.Attribute = d3.Attribute)
ORDER BY
  D.Object, d3.Attribute, d3.Method


--
Mark Derricutt

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

Reply via email to