title: SQL Server trigger using Inner join
body: <p>I am trying to create a trigger that fires only when the inserted last name into the classes table does not match the last names listed in the coaches table. </p>
  
  <p>Here is what I have but it seems to be firing no matter what is inserted into the table.:</p>
  
  <pre><code>CREATE TRIGGER CoachValidate
  ON CLASSES 
  FOR INSERT, UPDATE
  AS
  BEGIN
      IF exists (SELECT *
                 FROM inserted i
                 INNER JOIN COACHES c ON i.lastname &lt;&gt; c.lastname)
          RAISERROR('INVAILD COACH', 10, 0)
          ROLLBACK
  END
  </code></pre>
  
  <p>Can someone help me find the error?</p>