473,503 Members | 756 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

join question

Table Users
FName(text), LName(text), UserID(number)

Table Correspondence.
Date(datetime), msg_From(number), msg_To(number)

Table Users Data
John, Quincy, 1
Jane, Doe, 2

Table Correspondence Data
2/2/2002, 1, 2
Ideally the query would return a Record that would look like.

2/2/2002 John Quincy Jane Doe

At first I thought I could do this with a simple join but then realized I
could only join on the msg_from or the msg_to and not both
if I right join I can get both but unfortunately I can't figure out how to
get both Users on one row.

I figure maybe I need to use nested queries???

Keep in mind it has be usable in an access DB so T-SQL is not an option.

Thanks.

pejo.

Nov 12 '05 #1
1 1965
Simple: in the Query Builder, add the Correspondence table, then add the
Users table (twice). Join the From field to the UserId field in one copy.
Join the To field to the UserId field in the other copy of Users (Query
Builder will call it Users_1), then pull down the date field, and the First
and Last names fields from each copy of the Users table. Works exactly as
you want, and here's the SQL, copied unchanged from the Query Builder (note
I did change the name of the "Date" field to "CorrDate", because "Date" is
an Access reserved name and can, in some circumstances, lead to unexpected
results if used as a field name).

SELECT Correspondence.CorrDate, Users.FName, Users.LName, Users_1.FName,
Users_1.LName
FROM (Correspondence INNER JOIN Users ON Correspondence.msg_From =
Users.UserID) INNER JOIN Users AS Users_1 ON Correspondence.msg_To =
Users_1.UserID;

Larry Linson
Microsoft Access MVP

"Pejo" <po**********@hotmail.com> wrote in message
news:7q********************@news20.bellglobal.com. ..
Table Users
FName(text), LName(text), UserID(number)

Table Correspondence.
Date(datetime), msg_From(number), msg_To(number)

Table Users Data
John, Quincy, 1
Jane, Doe, 2

Table Correspondence Data
2/2/2002, 1, 2
Ideally the query would return a Record that would look like.

2/2/2002 John Quincy Jane Doe

At first I thought I could do this with a simple join but then realized I
could only join on the msg_from or the msg_to and not both
if I right join I can get both but unfortunately I can't figure out how to get both Users on one row.

I figure maybe I need to use nested queries???

Keep in mind it has be usable in an access DB so T-SQL is not an option.

Thanks.

pejo.

Nov 12 '05 #2

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

Similar topics

46
2412
by: Leo Breebaart | last post by:
I've tried Googling for this, but practically all discussions on str.join() focus on the yuck-ugly-shouldn't-it-be-a-list-method? issue, which is not my problem/question at all. What I can't...
0
3049
by: B. Fongo | last post by:
I learned MySQL last year without putting it into action; that is why I face trouble in formulating my queries. Were it a test, then you would have passed it, because your queries did help me...
1
3430
by: Paul Bramscher | last post by:
Here's one for pathological SQL programmers. I've got a table of things called elements. They're components, sort of like amino acids, which come together to form complex web pages -- as nodes...
4
14557
by: eXavier | last post by:
Hello, I have query joining several tables, the last table is joined with LEFT JOIN. The last table has more then million rows and execution plan shows table scan on it. I have indexed columns...
8
6307
by: kieran | last post by:
Hi, I have the following sql statement. I originally had the statement with two INNER JOINS but in some situations was getting an error so changed the last INNER JOIN to a LEFT OUTER JOIN (as...
3
1573
by: Jack Smith | last post by:
Hello, I want to be able to view data from 3 tables using the JOIN statement, but I'm not sure of how to do it. I think i don't know the syntax of the joins.I imagine this is easy for the...
3
23074
by: Ian Boyd | last post by:
i know nothing about DB2, but i'm sure this must be possible. i'm trying to get a client to create a view (which it turns out is called a "Logical" in DB2). The query needs a LEFT OUTER JOIN, but...
7
2506
by: germanshorthairpointer | last post by:
Hello, I'm trying to do a join based on the following tables: Person(person_id,person_name) Grade(grade_id,grade_person_id,grade_score) The data looks like this: Person:
27
2811
by: Paulo da Silva | last post by:
Hi! I was told in this NG that string is obsolet. I should use str methods. So, how do I join a list of strings delimited by a given char, let's say ','? Old way:
12
13156
by: Chamnap | last post by:
Hello, everyone I have one question about the standard join and inner join, which one is faster and more reliable? Can you recommend me to use? Please, explain me... Thanks Chamnap
0
7203
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7089
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7282
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7339
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6995
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
5017
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4678
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3168
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3157
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.