title: MySQL LEFT JOIN Multiple Conditions
body: <p>I have two tables: A and B linked by "group_id". <br />
  2 variables I'm using: <code>$keyword, $_SESSION['user_id']</code></p>
  
  <p><strong>A</strong><br />
  group_id<br />
  keyword<br /></p>
  
  <p><strong>B</strong><br />
  id<br />
  group_id<br />
  user_id<br /></p>
  
  <p>I want to be able to select all the groups that this user is not in based on a keyword search. </p>
  
  <p>Therefore the goal is to SELECT all the rows in A WHERE the user_id!={$_SESSION['user_id'} for the corresponding group_id in B AND like the keyword.   </p>
  
  <p>this is what I tried:</p>
  
  <pre><code>SELECT a.* 
  FROM a 
  LEFT JOIN b ON a.group_id=b.group_id 
  WHERE a.keyword LIKE '%".$keyword."%' 
  AND b.user_id!=$_SESSION{['user_id']} 
  GROUP BY group_id
  </code></pre>
  
  <p>However, it does not find any rows (matches) unless I remove <code>AND b.user_id!=$_SESSION{['user_id']}</code> in which case it will also include groups the user is already in - which is not what I want.</p>
  
  <p>Any help would be appreciated! Thanks</p>