I will try to make my question sound as unconfusing as possible. I declare any errors in the wording in advance, as I try to formulate my question as best as possible:
Using T-SQL I need to write a join statement that gets me all the results that have a match in table A and table B
And (!)
another join operator (or continuation of the first join) that returns all the results from table A that do NOT have a match in table B, but in this second set of results I need one of the columns to be set to "N / A" to identify records that did not match.
In other words, I need something that will return everything to table A, but will also identify rows that were not matched in B. This information is then used in the report.
Here is what I still have:
I have the first part:
LEFT OUTER JOIN dbo.chart B
ON B.UserName = A.user_name
It gives me matching entries and only matching entries
I tried to add this second connection:
JOIN dbo.chart
ON NOT EXISTS (select * from B.UserName = A.user_name)
Hoping this leads to a record that doesn't match me (I then planned to use REPLACE in the column of interest to label this column “N / A”), but there is something clearly wrong with my syntax, as it throws exceptions.
- , . , , . , , , , .
, . .
!
: , , , , , .