title: Help searching MYSQL database with a JOIN - possible self JOIN?
body: <p>In a View i have a table of users combining data from multiple database tables. The important tables are Users and Invitations. Im performing a join</p>
  
  <pre><code>LEFT JOIN invitations ON (users.id = invitations.invitee_id)
  </code></pre>
  
  <p>which gives me access to <code>users.invitee_id</code>, but i also have dynamic search parameters in my query and i cant search for an inviter by email because the inviter email is determined by using the invitee_id joined with the users table on user id. </p>
  
  <p>How can search for the inviter by email?</p>
  
  <p>heres the entire query</p>
  
  <pre><code>    ["SELECT users.id, users.login, users.email, invitations.inviter_id, FROM users 
        LEFT JOIN invitations ON (users.id = invitations.invitee_id)
        WHERE (users.email LIKE ? OR users.id LIKE ? OR users.login LIKE ?)",
        "%#{params[:search]}%","%#{params[:search]}%","%#{params[:search]}%"]
  </code></pre>
  
  <p><strong>schema</strong></p>
  
  <p>USERS: id, login, email</p>
  
  <p>INVITATIONS: id, inviter_id, invitee_id</p>