Query Help - if join critera is not met try another

millhouse123

Active Member
Joined
Aug 22, 2006
Messages
335
I have a very simple query that joins two table and returns all records that are NULL in table 2

Code:
SELECT Automated.Company, Automated.Account, Automated.ProfitCenter, Automated.Amount, [TrialBalance].Amount, UserName
FROM (Automated 
LEFT JOIN Conversion ON (Automated.Account=Conversion.[Mil Account]) AND (Automated.Company=Conversion.[Mil Company]) AND (Automated.ProfitCenter=Conversion.[MIL Profit Center])) 
WHERE Conversion.[SAP Account] IS Null AND Conversion.[SAP Profit Center] is NULL AND Conversion.[SAP Company] is NULL;


Table 1 = Automated
Table 2 = Conversion

The conversion is joined on Company, Account and Profit Center

What I would like to do is take the records that the query above returns and replace automated.profitcenter with 000000. So I would like the query then to return not only those that now join but those that still do not join. See example below
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
What I would like to do is take the records that the query above returns and replace automated.profitcenter with 000000
Easiest way you colud accomplish this would be to create an update query and use the first query as the source. You will have to format the table field to hold all those zero placeholders.
So I would like the query then to return not only those that now join but those that still do not join.
This I don't understand. Joins do influence what records will be returned when dealing with more than one table, but you can return records for fields that are not joined as well. It is the criteria on the query fields that controls this.

You probably noticed that your example was not included in your post.
 
Upvote 0

Forum statistics

Threads
1,221,832
Messages
6,162,254
Members
451,757
Latest member
iours

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top