Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to make the FROM-part of the SELECT-statement? Outer join? 1

Status
Not open for further replies.

ViAn

Technical User
May 7, 2003
30
NO
I have three tables representing the same series of measurements, but not all measurements are present in all tables:
Code:
One
Two
ControlTable (this table should include all measurements)
To simplify, all of them have these two columns/fields:
Code:
PK 
field1
(PK is the primary key,and is also an index identifying the actual measurement.)

1) I would now want to select field1 from both tables One and Two. I would like NULLs to be added if the same PK does not exist in both of the tables (implicates "full outer join"?). How should the FROM-statement be composed?

2) Is it possible to order by "ControlTable.PK" even if some measurements might miss in this table? (The intention is that all measurements sould be present in this table).

To clarify my question, this is what I want to be done:

Code:
SELECT One.field1, Two.field1
FROM ???
WHERE (ControlTable.field1 > 1)
ORDER BY ControlTable.PK
Thank you in advance!

YS ViAn
 
There's no need for a FULL OUTER JOIN if
"ControlTable (this table should include all measurements)"
is true.

SELECT One.field1, Two.field1
FROM ControlTable LEFT JOIN One
ON ControlTable.PK = One.PK
LEFT OUTER JOIN Two
ON ControlTable.PK = Two.PK
WHERE (ControlTable.field1 > 1)
ORDER BY ControlTable.PK

Dieter
 
Now it worked out as it was supposed to. A star to you!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top