title: Select all rows that has either A=B OR C=D EXCEPT where ID=foo in MySQL
body: <p>I am trying to select all rows that has either the same username OR email as any users EXCEPT the one with ID 7.</p>
  
  <p>But now it returns the row that actually has the ID 7. I was thinking that perhaps you can do some grouping of your SQL to solve this?</p>
  
  <p>Can anyone tell me whats wrong?</p>
  
  <p>This is my SQL that I am trying with in MySQL:</p>
  
  <pre><code>SELECT user_id FROM user WHERE username = "my_username" OR email = "my@email.com" AND user_id != 7
  </code></pre>
  
  <p>Previous I was running this in SQLite3 which worked fine for the purpose. But since MySQL does not support the EXCEPT this will not work in MySQL:</p>
  
  <pre><code>SELECT COUNT(*) FROM user WHERE username = :username OR email = :email EXCEPT SELECT COUNT(*) FROM user WHERE user_id = :user_id
  </code></pre>
  
  <p>Thanks in advance!</p>