View Single Post
  #1 (permalink)  
Old January 28th, 2008, 09:36 AM
snufse snufse is offline
Friend of Wrox
 
Join Date: Mar 2007
Location: West Palm Beach, Florida, USA.
Posts: 205
Thanks: 4
Thanked 0 Times in 0 Posts
Default Retrieve records from 2 tables

I need to retrieve data from 2 tables (I have a sp that populates each table)regardless if they have a match or not.

First table:
#JobListTable
job_date datetime,
job_number char(15),
job_phase char(15),
qty_delivered decimal(8,2)

Second table:
#EquentialJobListTable
job_date datetime,
job_number char(15),
job_phase char(15),
qty_received decimal(8,2)

There could be a match between the two tables, or a record could exist in one and not in the other. The matching key will be the first 3 fields from each table. Result will be loaded into a DataSet and DataGrid

This is what I have. Not sure if it is correct approach.

SELECT #JobListTable.job_date, #JobListTable.job_number, #JobListTable.job_phase, #JobListTable.qty_delivered, #EquentialJobListTable.job_date, #EquentialJobListTable.job_number, #EquentialJobListTable.job_phase, #EquentialJobListTable.qty_received
FROM #JobListTable FULL OUTER JOIN #EquentialJobListTable
        ON #JobListTable.job_date = #EquentialJobListTable.job_date and #JobListTable.job_number = #EquentialJobListTable.job_number and #JobListTable.job_phase = #EquentialJobListTable.job_phase

Regardless of match or not, I only want to to see job_date, job_number and job_phase one time and not from both tables