473,322 Members | 1,620 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

SQL - return records where both values on join are null

Hi

I have the following query:

SELECT qryBlackbook.*
FROM qryBlackbook inner JOIN qryLatestMeetingDate ON
(qryBlackbook.Site_Ref = qryLatestMeetingDate.Site_Ref) AND
(qryBlackbook.MeetingDate = qryLatestMeetingDate.LatestDate);

is there a way to adjust it so that it will also return records where
both qryBlackbook.MeetingDate and qryLatestMeetingDate.LatestDate are
null?

Thanks
Paul

Nov 7 '07 #1
4 1825
On Nov 7, 8:15 am, "paulquinlan...@hotmail.com"
<paulquinlan...@hotmail.comwrote:
Hi

I have the following query:

SELECT qryBlackbook.*
FROM qryBlackbook inner JOIN qryLatestMeetingDate ON
(qryBlackbook.Site_Ref = qryLatestMeetingDate.Site_Ref) AND
(qryBlackbook.MeetingDate = qryLatestMeetingDate.LatestDate);

is there a way to adjust it so that it will also return records where
both qryBlackbook.MeetingDate and qryLatestMeetingDate.LatestDate are
null?

Thanks
Paul
Yes. What you want is an full outer join. Although Access doesn't
have a full outer join, it can be simulated with a union of a left
join and and a right join.

Nov 7 '07 #2
Hi

I tried to do as you said using the query below:

SELECT qryBlackbook.*
FROM qryBlackbook LEFT JOIN qryLatestMeetingDate ON
(qryBlackbook.MeetingDate = qryLatestMeetingDate.LatestDate) AND
(qryBlackbook.Site_Ref = qryLatestMeetingDate.Site_Ref)
UNION
SELECT qryBlackbook.*
FROM qryBlackbook RIGHT JOIN qryLatestMeetingDate ON
(qryBlackbook.Site_Ref = qryLatestMeetingDate.Site_Ref) AND
(qryBlackbook.MeetingDate = qryLatestMeetingDate.LatestDate);

however, it still is not pulling through the records where both dates
are null, any ideas?

Thanks again
Paul
On 7 Nov, 14:40, OldPro <rrossk...@sbcglobal.netwrote:
On Nov 7, 8:15 am, "paulquinlan...@hotmail.com"

<paulquinlan...@hotmail.comwrote:
Hi
I have the following query:
SELECT qryBlackbook.*
FROM qryBlackbook inner JOIN qryLatestMeetingDate ON
(qryBlackbook.Site_Ref = qryLatestMeetingDate.Site_Ref) AND
(qryBlackbook.MeetingDate = qryLatestMeetingDate.LatestDate);
is there a way to adjust it so that it will also return records where
both qryBlackbook.MeetingDate and qryLatestMeetingDate.LatestDate are
null?
Thanks
Paul

Yes. What you want is an full outer join. Although Access doesn't
have a full outer join, it can be simulated with a union of a left
join and and a right join.- Hide quoted text -

- Show quoted text -

Nov 7 '07 #3
On Nov 7, 9:15 am, "paulquinlan...@hotmail.com"
<paulquinlan...@hotmail.comwrote:
Hi

I have the following query:

SELECT qryBlackbook.*
FROM qryBlackbook inner JOIN qryLatestMeetingDate ON
(qryBlackbook.Site_Ref = qryLatestMeetingDate.Site_Ref) AND
(qryBlackbook.MeetingDate = qryLatestMeetingDate.LatestDate);

is there a way to adjust it so that it will also return records where
both qryBlackbook.MeetingDate and qryLatestMeetingDate.LatestDate are
null?

Thanks
Paul
I don't have simlar construction to test but I would try:
SELECT qryBlackbook.*
FROM qryBlackbook inner JOIN qryLatestMeetingDate ON
(qryBlackbook.Site_Ref = qryLatestMeetingDate.Site_Ref)
AND
(
(qryBlackbook.MeetingDate = qryLatestMeetingDate.LatestDate)
OR
(qryBlackbook.MeetingDate Is Null AND qryLatestMeetingDate.LatestDate
Is Null)
)

/*extra lines to help me get brackets right*/

I think the nature of the records returned by the two subqueries might
make this solution OK. Then again it might be useless.

Nov 8 '07 #4
I tried to do as you said using the query below:
>
SELECT qryBlackbook.*
FROM qryBlackbook LEFT JOIN qryLatestMeetingDate ON
(qryBlackbook.MeetingDate = qryLatestMeetingDate.LatestDate) AND
(qryBlackbook.Site_Ref = qryLatestMeetingDate.Site_Ref)
UNION
SELECT qryBlackbook.*
FROM qryBlackbook RIGHT JOIN qryLatestMeetingDate ON
(qryBlackbook.Site_Ref = qryLatestMeetingDate.Site_Ref) AND
(qryBlackbook.MeetingDate = qryLatestMeetingDate.LatestDate);

however, it still is not pulling through the records where both dates
are null, any ideas?
You are only selecting records from the one table: SELECT
qryBlackbook.*
One of the joins should select records from the other table.

Nov 8 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Edward | last post by:
SQL Server 7.0 If I run the following in Query Analyzer I get no records returned: exec GetLeadsOutcome_Dealer '1/1/2003','12/2/2003',10, '176, 183' If, however, I run either : exec...
6
by: cjm | last post by:
I need to group records and assign a setid to the group. I have a table with data that looks like this ColA ColB 94015 01065 94016 01065 94015 01085 94015 01086 33383 00912 32601 00912
2
by: Tom Gao | last post by:
I have a problem. The project that I'm working on requires me to duplicate records. As in a series of records are entered into the system the user then click on a button to make these as...
1
by: dbuchanan | last post by:
VB.NET 2003 / SQLS2K The Stored Procedure returns records within Query Analyzer. But when the Stored Procedure is called by ADO.NET ~ it produced the following error message. ...
1
by: Robert Marshall | last post by:
Hi all, Hoping someone can help me with an issue I'm having. I'm using AccessXP to create a database of U.S. Census records. After keying the data in, I decided to run a query to create a...
2
by: MLH | last post by:
We have a table (tblClients) with several thousand records. Because of organizational structure, changes to those records are maintained in a separate database. Weekly, about a dozen or so clients...
2
by: kevinjbowman | last post by:
I am by no means a SQl Jedi as will be apparent by my question, but I can usually figure out a select statement on my own. I have one today though that really has me stumped. I am working in...
2
by: smcirish | last post by:
- My left table V1 will sometimes have a value of NULL for V1.prog_log_key - I am trying to join this field, to the right table H1 FROM dbo.V_HEAD_DETAIL_Program AS V1 LEFT OUTER JOIN...
7
Claus Mygind
by: Claus Mygind | last post by:
I have two tables employee and time. Both contain the common field EMPNO. I want to link the tables on the EMPNO and find all records within a specific date range. But I also want to include any...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.