title: MySQL: Select whether or not user is in another table
body: <p><em>Keep in mind there's more to both the statement and the tables, but I'll keep it short for easier reading.</em></p>
  
  <p>I'm trying to get whether or not a user has been in a shop or not. The tables look like this. </p>
  
  <pre><code>--Shop--
  ShopID
  
  --Visit--
  ShopID
  UserID
  </code></pre>
  
  <p>And the following is how far I've come at the moment.</p>
  
  <pre><code>SELECT shop.ShopID, visit.UserID AS Visited FROM shop
  LEFT OUTER JOIN visit ON shop.ShopID = visit.ShopID
  WHERE UserID = 1
  </code></pre>
  
  <p>The problem with this code is that it will not show NULL for visits that's not UserID 1. I've tried to add <code>OR UserID IS NULL</code> to the statement, but it just leaves me with all the shops that has not been visited by any user. </p>
  
  <p>I could filter it by checking whether <code>Visited</code> is the same as the UserID or not, but it would be a lot easier if the database could write it as 1 and 0. So to ask specific: </p>
  
  <p>How do I make <code>Visited</code> output 0 or 1 based on if there's a UserID 1 connected with the ShopID in the Visit-table?</p>