title: Where clause with multiple OR
body: <p>I was trying to access list of foods with which has restaurant_id = 2 and if the food_id in carts table it should print cart_id and if the food_id in favorites table it should print favorite_id otherwise it will return null. But the problem i'm facing here is food_id i'm getting from that specific restaurant but while checking the carts and favorites id it fails to check for the user_id. </p>
  
  <p>food_id is in the carts table but not for that user but it shows that cart_id. How do i make the query correct? </p>
  
  <pre><code>Foods table: id, restaurant_id
  Carts Table: id, user_id, food_id
  Favorites Table: id, user_id, food_id
  </code></pre>
  
  <p><strong>SQL QUERY:</strong></p>
  
  <pre><code>SELECT foods.id, carts.id as cart_id , favorites.id as favorite_id 
  FROM foods 
  LEFT JOIN carts 
  ON carts.food_id= foods.id 
  LEFT JOIN favorites 
  ON favorites.food_id= foods.id 
  WHERE foods.restaurant_id = 2 
  AND (carts.user_id = 1 OR favorites.user_id = 1)
  </code></pre>