thefrstgatsby
Technical User
The first part of this message is a repost which was already answered, but after we decided the problem was solved, I realized there was one more thing that I need help on. So the question is at the bottom since the backstory to this is needed to understand.
Clients (table A) Service Prov (table b)
Name Transaction IDc Provider Transactionsp ID
------ --------------- -------- ----------------
Joe 434 Mary 434
Transactions table
Transaction IDt
---------------
434
Not doing business Anymore
--------------------------
Client Name Provider Name
----------- -------------
Joe Mary
So I need to pull all transactions from the Transactions table with the same transaction code, but only if there is a record in the Not Doing Business Anymore Which is related to the client and service provider tables via Client name and Provider Name. Plus I need to pull the record from the not doing business anymore as well.
Here is the solution, which does work in pulling the required records...
SELECT ...ListOfColumns...
FROM Transactions AS t
INNER JOIN Clients AS c
ON t.[Transaction IDt] = c.[Transaction IDc]
INNER JOIN [Service Prov] AS sp
ON t.[Transaction IDt] = sp.[Transactionsp ID]
INNER JOIN [Not doing business Anymore] AS ndba
ON c.[Name] = ndba.[Client Name]
AND sp.Provider = ndba.[Provider Name]
********However, here is the problem*********
And my question*****
when it returns the value for a row, if for example I have a column in the Not doing business Anymore table called "reason", it will copy that reason over any row associated with that record.
So let's say there was a transaction record for joe and mary under the transaction table, and then in the Not doing business Anymore table there is an associated table.
Instead of showing:
date client provider reason
02/16/2005 Joe Mary ------
03/17/2005 Joe Mary unhappy with service.
Which is what I want it to show, since the first row (02/16/2005) is only a transaction, and therefore the reason field should be blank, it shows the following:
date client provider reason
02/16/2005 Joe Mary unhappy with service.
03/17/2005 Joe Mary unhappy with service.
I tried a left join between the client / provider tables
and the "Not doing business anymore" table, but then it ends up returning more rows, which definitely should not exist.
What kind of join should I be making, or what should I change in order to make it work?
Clients (table A) Service Prov (table b)
Name Transaction IDc Provider Transactionsp ID
------ --------------- -------- ----------------
Joe 434 Mary 434
Transactions table
Transaction IDt
---------------
434
Not doing business Anymore
--------------------------
Client Name Provider Name
----------- -------------
Joe Mary
So I need to pull all transactions from the Transactions table with the same transaction code, but only if there is a record in the Not Doing Business Anymore Which is related to the client and service provider tables via Client name and Provider Name. Plus I need to pull the record from the not doing business anymore as well.
Here is the solution, which does work in pulling the required records...
SELECT ...ListOfColumns...
FROM Transactions AS t
INNER JOIN Clients AS c
ON t.[Transaction IDt] = c.[Transaction IDc]
INNER JOIN [Service Prov] AS sp
ON t.[Transaction IDt] = sp.[Transactionsp ID]
INNER JOIN [Not doing business Anymore] AS ndba
ON c.[Name] = ndba.[Client Name]
AND sp.Provider = ndba.[Provider Name]
********However, here is the problem*********
And my question*****
when it returns the value for a row, if for example I have a column in the Not doing business Anymore table called "reason", it will copy that reason over any row associated with that record.
So let's say there was a transaction record for joe and mary under the transaction table, and then in the Not doing business Anymore table there is an associated table.
Instead of showing:
date client provider reason
02/16/2005 Joe Mary ------
03/17/2005 Joe Mary unhappy with service.
Which is what I want it to show, since the first row (02/16/2005) is only a transaction, and therefore the reason field should be blank, it shows the following:
date client provider reason
02/16/2005 Joe Mary unhappy with service.
03/17/2005 Joe Mary unhappy with service.
I tried a left join between the client / provider tables
and the "Not doing business anymore" table, but then it ends up returning more rows, which definitely should not exist.
What kind of join should I be making, or what should I change in order to make it work?