Thread: Right Joins
View Single Post
  #2  
Old February 15th, 2007, 04:44 PM posted to microsoft.public.access.queries
Jason Lepack
external usenet poster
 
Posts: 600
Default Right Joins

1) I don't think you mean to use a right join.

After all, why bother using a right join if you're going to use the
table that will have null values in your WHERE clause?

Essentially what you're doing is this:
table1:
Field1, Field2
1, hello
2, goodbye
3, hooray

table2:
Field1
1
2
3
4
5

Query1:
SELECT table2.Field1, table1.field1, table1.field2
FROM table1 RIGHT JOIN table2
ON table1.Field1 = table2.Field1

will return:
1, 1, hello
2, 2, goodbye
3, 3, hooray
4, null, null
5, null, null

So if I used table A's info in my WHERE clause I would get this:
Query2:
SELECT table2.Field1, table1.field1, table1.field2
FROM table1 RIGHT JOIN table2
ON table1.Field1 = table2.Field1
WHERE table1.field2 is not null

returns:
1, 1, hello
2, 2, goodbye
3, 3, hooray

I might as well have used an inner join and avoided the where clauses.

So "probably" either your WHERE clauses point at the wrong table or
your join should be a LEFT JOIN

Cheers,
Jason Lepack

On Feb 15, 11:01 am, Welthey
wrote:
I have the following query which I have used before with the same joins, but
it is not populating the validation question like I need it to do. Can
someone take a quick look and try to explain to me what I may be doing wrong.

SELECT tblAMUWork.AMUWrkID, tblAMUWork.DateRcd, tblAMUWork.IncomingKeyedBy,
tblAMUWork.WorkOfDate, tblAMUWork.AmtRcd, tblAMUWork.TypeOfWork,
tblAMUWork.MISNumber, tblAMUWork.RptName, tblAMUWork.RepAssgnd,
tblAMUWork.CompletedDate, tblAMUWork.CompletedAmt, tblAMUWork.CompletedAmt1,
tblAMUWork.CompletedDate1, tblAMUWork.CompletedAmt2,
tblAMUWork.CompletedDate2, tblAMUWork.CompletedAmt3,
tblAMUWork.CompletedDate3, tblAMUWork.WorkNotCompleted,
tblAMUWork.TotalAmtCompleted, tblAMUWork.EODKeyedBy, tblAMUWork.EODKeyedBy1,
tblAMUWork.EODKeyedBy2, tblAMUWork.EODKeyedBy3, tblAMUWork.ExceptionDate,
tblAMUWork.RsnForChng, tblAMUWork.WhatChgd, tblAMUWork.CngMdBy,
tblAMUWork.VolReferred, tblAMUWork.DATEVLDTD, tblAMUWork.NUMBEROFACCTSVLDTD,
tblAMUWork.VLDTNCOMPBY, tblAMURptsRecd.VALQuestions, tblAMUWork.Acct1,
tblAMUWork.Answer1, tblAMUWork.Acct2, tblAMUWork.Answer2, tblAMUWork.Acct3,
tblAMUWork.Answer3, tblAMUWork.Acct4, tblAMUWork.Answer4, tblAMUWork.Acct5,
tblAMUWork.Answer5, tblAMUWork.[Audited By], tblAMUWork.FindingstoInvest,
tblAMUWork.DateofData, tblAMUWork.VolumesMatched,
tblAMUWork.InvestRsltsFinalDocumd, tblAMUWork.BthHdrMtchsComet,
tblAMUWork.MISMtchsBatch, tblAMUWork.MISMtchsComet, tblAMUWork.Discrepancies,
tblAMUWork.BatchNum, tblAMUWork.CometNum, tblAMUWork.MISDNWNum,
tblAMUWork.MISRvwsNum, tblAMUWork.Comments
FROM tblAMUWork RIGHT JOIN tblAMURptsRecd ON tblAMUWork.RptName =
tblAMURptsRecd.AMUReportName
WHERE (((tblAMUWork.DateRcd)=[Enter the date that the work was received])
AND ((tblAMUWork.MISNumber)=[Enter the MIS number ( located to the left of
the report name)]));