title: Match two Columns in SQL Join
body: <p>I have following Table Structure :</p>
  
  <p>Table: CashStatus (Can have duplicate entries for "ATM")</p>
  
  <pre><code>ATM  Cash   Device
  A01  55     BASE
  A01  1      IST
  A02  1      BASE
  A02  78     IST
  </code></pre>
  
  <p>Table : ATM (Unique Entry for ATM Column)</p>
  
  <pre><code>ATM   DEVICE
  A01   BASE
  A02   IST
  </code></pre>
  
  <p>I want to retreive only those rows from <code>CashStatus</code> table who's <code>ATM &amp; Device</code> Column matches with as with <code>ATM</code> Table</p>
  
  <p>I did some research and tried the following query:-</p>
  
  <pre><code>SELECT *
    FROM CashStatus 
   WHERE EXISTS (SELECT 'X'
                   FROM ATM
                  WHERE ATM = TermId collate SQL_Latin1_General_CP1_CI_AS
                 AND DeviceName = Devicetype collate SQL_Latin1_General_CP1_CI_AS);
  </code></pre>
  
  <p>But it gives error : <code>Expression type int is invalid for COLLATE clause.</code></p>