title: Only use data from TableA when TableB has no matching entry
body: <p>So i have: </p>
  
  <p>Table A with (not only Name - Multiple Columns):</p>
  
  <pre><code>| IDA        | Name        |
  |:-----------|------------:|
  | 1          |        John |
  | 2          |       Jonas | 
  | 3          |        Carl | 
  | 4          |         Foo |
  | 5          |         Bar |
  | 6          |         Dog |
  </code></pre>
  
  <p>Table B with (not only Name - Multiple Columns):</p>
  
  <pre><code>| IDB        | Name        |
  |:-----------|------------:|
  | 1          |         Bob |
  | 2          |        Lisa | 
  </code></pre>
  
  <p>Table MAIN with:</p>
  
  <pre><code>| ID         | FKtoB       | FKtoA       |
  |:-----------|------------:|------------:|
  | 1          |           1 |           4 |
  | 2          |             |           3 | 
  | 3          |             |           1 | 
  | 4          |           2 |           6 |
  | 5          |             |           2 |
  | 6          |             |           5 |
  </code></pre>
  
  <p>My goal is to select from MAIN and prefer to use the data of Table B but if not Available i will use the data of Table A. I tryed to use <a href="https://docs.microsoft.com/en-us/sql/t-sql/language-elements/coalesce-transact-sql" rel="nofollow noreferrer">coalesce</a> but that didn't help because i dont want to mix the data, so if for example Table B has the data for one row, then in this row there should be no data from Table A.</p>
  
  <p>My Query looks like that:</p>
  
  <pre><code>select 
  coalesce(b.name, a.name) as surname, coalesce(b.surname, a.surname) as surname 
  from MAIN m
  left join TableA a on a.IDA = m.FKtoA
  left join TableB b on b.IDA = m.FKtoB
  </code></pre>
  
  <p>My Problem there is that if for example b.name is filled and b.surname isn't it would mix b.name with a.surname, thats not okay in my case.</p>