title: How to use UPDATE IIF
body: <p>I am using SQL in MS-Access.
  I created some queries that analyze if a code is present in two different excel spreadsheets and generate a new table, informing "yes" or "no" for each comparison.</p>
  
  <p>However, sometimes, a certain code appears in just one table, but after a while (when someone update the excel spreadsheets), that code appears.</p>
  
  <p>I already have a query that makes this comparison, but it doesn't work for those codes that are introduced in the table AFTER the comparison has already been made.</p>
  
  <p>So, I would like to create a query that uses an UPDATE, checking if the given code is now in both tables, and if it is, it would update the comparison column of my table.</p>
  
  <p>This is the query I created for this, but it is not working:</p>
  
  <pre><code>UPDATE 
  
    comparationTable
  
  SET 
  
    col_comp = IIf(spreadSheet1.code = spreadSheet2.code),"Yes","******No******")
  
  WHERE 
  
    code1 = code2;
  </code></pre>
  
  <p>Note: code1 and code2 are columns that only show the code coming from excel spreadsheet1 and excel spreadsheet2, respectively.</p>
  
  <p>Edit: Here's the images of the two spreadsheets (sp1, sp2) and the comparation table: <a href="https://i.stack.imgur.com/fi7iJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fi7iJ.png" alt="sp1"></a></p>
  
  <p><a href="https://i.stack.imgur.com/QiJrJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QiJrJ.png" alt="sp2"></a></p>
  
  <p><a href="https://i.stack.imgur.com/imHHA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/imHHA.png" alt="comparation Table"></a></p>