I have three tables. LP, TA and PR. I need to create a report that selects only those records in LP which have one or more matching records in either the TA or the PR table (or it could have multiple matches in both). I created a report with records from LP and two sub reports with records from TA and LP, but of course I get records that don't have entries in either table. I tried to create a query using joins, but it gave me an error message about an ambigous outer join. I tried to create a separate query and use that, as the error message said to do, but I can't seem to get anything to work. I finally created a make table query and an append query to select the matching records from one table and then append matching records from another and based the report on that new table and it works, but it is so clumsy and I need some additional reports so I don't want to continue that.
My fields that I'm working with are:
LP table
license number
Site name
City
ABC
and some other fields.
TA table
license number
Type
Consultant
Date Completed
PR table
license number
type
Scale
Consultant
Date Completed
I would be most appreciative of some help (in newbie language). I tried searching for other posts with "Joins" but I coudn't find anything that I could make work. Thanks so much.
5 1379 Rabbit 12,516
Recognized Expert Moderator MVP
I have three tables. LP, TA and PR. I need to create a report that selects only those records in LP which have one or more matching records in either the TA or the PR table (or it could have multiple matches in both). I created a report with records from LP and two sub reports with records from TA and LP, but of course I get records that don't have entries in either table. I tried to create a query using joins, but it gave me an error message about an ambigous outer join. I tried to create a separate query and use that, as the error message said to do, but I can't seem to get anything to work. I finally created a make table query and an append query to select the matching records from one table and then append matching records from another and based the report on that new table and it works, but it is so clumsy and I need some additional reports so I don't want to continue that.
My fields that I'm working with are:
LP table
license number
Site name
City
ABC
and some other fields.
TA table
license number
Type
Consultant
Date Completed
PR table
license number
type
Scale
Consultant
Date Completed
I would be most appreciative of some help (in newbie language). I tried searching for other posts with "Joins" but I coudn't find anything that I could make work. Thanks so much.
-
SELECT DISTINCT [LP Table].[License Number]
-
FROM (([LP Table] INNER JOIN [TA Table] ON [LP Table].[License Number] = [TA Table].[License Number]) INNER JOIN [PR Table] ON [LP Table].[License Number] = [PR Table].[License Number]);
-
This seems to be selecting the records that have an entry in both tables, but not those that have an entry in only one table or the other as well. Also, it occurred to me that for my purposes it would be better to select from a query that is checking the date rather than the table. I am assuming I can substitute the query name for the table name? Thanks again so much for the help.
Rabbit 12,516
Recognized Expert Moderator MVP -
SELECT DISTINCT [LP Table].[License Number]
-
FROM [LP Table] INNER JOIN [TA Table] ON [LP Table].[License Number] = [TA Table].[License Number]
-
UNION
-
SELECT DISTINCT [LP Table].[License Number]
-
FROM [LP Table] INNER JOIN [PR Table] ON [LP Table].[License Number] = [PR Table].[License Number];
-
THAT SO WORKS!!! Thank you so very much! I can't tell you how wonderful it is to have someone willing to help.
Rabbit 12,516
Recognized Expert Moderator MVP
THAT SO WORKS!!! Thank you so very much! I can't tell you how wonderful it is to have someone willing to help.
Not a problem, good luck.
And I missed your question the first time around but yes, you can use query names instead of table names.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: jgalzic |
last post by:
Hi,
I'm having trouble doing joins correctly on two tables. I've read up a
lot about the different types of joins and tried lots of variations on
inner, outer, and left joins with no avail....
|
by: Prem |
last post by:
Hi,
I am having many problems with inner join. my first problem is :
1) I want to know the precedance while evaluating query with multiple
joins.
eg.
select Employees.FirstName,...
|
by: Sri |
last post by:
I am writing a download process in which i have a condition where i
need to join four tables. Each table have lot of data say around
300000 recs.
my question is when i am doing the joins on...
|
by: jbm05 |
last post by:
Hi,
I'm curious about the computational complexity of a query I have. The
query contains multiple nested self left joins, starting with a simple
select, then doing a self left join with the...
|
by: Steve |
last post by:
I have a SQL query I'm invoking via VB6 & ADO 2.8, that requires three
"Left Outer Joins" in order to return every transaction for a specific
set of criteria.
Using three "Left Outer Joins"...
| |
by: Lumpierbritches |
last post by:
I'm trying to pull all the parents of a particular animal and I have my SQL
statement that says not supported and when I attempt to run the Query, I get
The SQL statement couldn't be executed...
|
by: Brian Parker |
last post by:
I'm new to ms-sqlserver ( 2000 ) and need to get an OUTER JOIN working
on a three table query.
Assumptions:
-- I have events in the Event table.
-- Each event CAN have one Transaction, but it's...
|
by: gkellymail |
last post by:
the following query works fine:
select link.idx, link.x_table, link.x_id_a, link.x_id_z, a.strandid,
b.strandid
from link_detail, link, strand A, strand B
where link_detail.x_table =...
|
by: shapper |
last post by:
Hello,
I am used to SQL but I am starting to use LINQ.
How can I create Left, Right and Inner joins in LINQ? How to
distinguish the different joins?
Here is a great SQL example:...
|
by: TC |
last post by:
I've used Access for many years. Several times, I've encountered a bug
which I refer to as the "Vanishing Joins" bug. When it happens, joins
vanish randomly from queries. More specifically, all...
|
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...
| |
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...
|
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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
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...
|
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...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |