Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 MS Access
 Can't right outer Join!

Author  Topic 

ptspawn
Starting Member

1 Post

Posted - 2011-11-17 : 17:37:13
Hi Everyone,

I'm just starting on SQL and I really need help.

I'm using access to match a few values on one table to other values on another table (essentially I'm matching passenger flow on subway stations to the equivalent train trip).

I thought everything was ok util I noticed I lost values because since some trips don't have passengers, when I matched them they didn't appear. I read about the outer joins, but cant seem to make them work.

Anyway, here is my original code:

SELECT Main.[Num Comboio], Main.[Data Operacional], Main.[Tipo Dia], Main.[Hora Inicial], Main.[Hora Final], Format(([UnsortedDataProc].[Hora Final]-[UnsortedDataProc].[Hora Inicial])/2+[UnsortedDataProc].[Hora Inicial],"hh:nn:ss") AS [Hora Média], UnsortedDataProc.Linha, Main.[Num Rotação], UnsortedDataProc.Sentido, Main.[Cod Rotação], UnsortedDataProc.[Entradas 1], UnsortedDataProc.[Saidas 1], UnsortedDataProc.[Validações 1], UnsortedDataProc.[Entradas 2], UnsortedDataProc.[Saidas 2], UnsortedDataProc.[Validações 2], UnsortedDataProc.[Entradas 3], UnsortedDataProc.[Saidas 3], UnsortedDataProc.[Validações 3], UnsortedDataProc.[Entradas 4], UnsortedDataProc.[Saidas 4], UnsortedDataProc.[Validações 4], UnsortedDataProc.[Entradas 5], UnsortedDataProc.[Saidas 5], UnsortedDataProc.[Validações 5], UnsortedDataProc.[Entradas 6], UnsortedDataProc.[Saidas 6], UnsortedDataProc.[Validações 6], UnsortedDataProc.[Entradas 7], UnsortedDataProc.[Saidas 7], UnsortedDataProc.[Validações 7], UnsortedDataProc.[Entradas 8], UnsortedDataProc.[Saidas 8], UnsortedDataProc.[Validações 8], UnsortedDataProc.[Entradas 9], UnsortedDataProc.[Saidas 9], UnsortedDataProc.[Validações 9], UnsortedDataProc.[Entradas 10], UnsortedDataProc.[Saidas 10], UnsortedDataProc.[Validações 10], UnsortedDataProc.[Entradas 11], UnsortedDataProc.[Saidas 11], UnsortedDataProc.[Validações 11], UnsortedDataProc.[Entradas 12], UnsortedDataProc.[Saidas 12], UnsortedDataProc.[Validações 12], UnsortedDataProc.[Entradas 13], UnsortedDataProc.[Saidas 13], UnsortedDataProc.[Validações 13], UnsortedDataProc.[Entradas 14], UnsortedDataProc.[Saidas 14], UnsortedDataProc.[Validações 14], UnsortedDataProc.[Entradas 15], UnsortedDataProc.[Saidas 15], UnsortedDataProc.[Validações 15], UnsortedDataProc.[Entradas 16], UnsortedDataProc.[Saidas 16], UnsortedDataProc.[Validações 16], UnsortedDataProc.[Entradas 17], UnsortedDataProc.[Saidas 17], UnsortedDataProc.[Validações 17], UnsortedDataProc.[Entradas 18], UnsortedDataProc.[Saidas 18], UnsortedDataProc.[Validações 18], UnsortedDataProc.[Entradas 19], UnsortedDataProc.[Saidas 19], UnsortedDataProc.[Validações 19], UnsortedDataProc.[Entradas 20], UnsortedDataProc.[Saidas 20], UnsortedDataProc.[Validações 20] INTO WorkTable

FROM UnsortedDataProc, Main
WHERE (((Format(([UnsortedDataProc].[Hora Final]-[UnsortedDataProc].[Hora Inicial])/2+[UnsortedDataProc].[Hora Inicial],"hh:nn:ss")) Between [Main].[Hora Final] And [Main].[Hora Inicial]) AND ((UnsortedDataProc.Linha)=[Main].[Num Linha]) AND ((UnsortedDataProc.[Data Operacional])=[Main].[Data Operacional]));



I need to make a right outer join, but every way I've read online has failed me and I'm running out of ideas.

Please help

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-11-17 : 18:26:11
Which tables has the trips? And on what columns do you join on between these two tables?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -