title: Replace certain values by the means of a table with replacement values
body: <p>I have a table with data in it. Generally the values are correct but sometimes we need to modify them. The modifications are saved in a second table.</p>
  
  <p>I wanted to create a query that dynamically replaces the values if they exist in the replacement table.</p>
  
  <p>This is what my query design looks like but it doesn't work:
  <img src="https://i.stack.imgur.com/fmL7w.png" alt="query design"></p>
  
  <p>This is my query code:</p>
  
  <pre><code>SELECT
    b.Pos,
    b.Posten,
    IsNull(c.Wert_Neu, b.Bez1) AS Bez1,
    IsNull(c.Wert_Neu, b.Bez2) AS Bez2,
    IsNull(c.Wert_Neu, b.Bez3) AS Bez3,
    b.Wert,
    b.Einheit
  FROM
    Table_Values b LEFT JOIN
    Table_Replacements c ON b.Bez1 = c.Wert_Alt AND b.Bez2 = c.Wert_Alt AND b.Bez3 = c.Wert_Alt
  </code></pre>
  
  <p>Where is my logical error? It doesn't replace the values. I assume it has something to do with the joins all going there without OR, but OR would be too costly for performance.</p>
  
  <p>Anyone with a better idea?</p>