title: Nested SQL Query from multiple tables and COUNT inline
body: <p>Good day bloggers.</p>
  <p>I want to create a query which will select <code>car name</code>, <code>model</code>, <code>price</code> from table <code>tblCars</code>. Within the same query result, I need to check from table <code>tblLikes</code> if certain user has liked the car. <code>tblLikes</code> has <code>id</code>, <code>userId</code> and <code>carId</code> (foreign key). So for a specific user I need something like the following in return.</p>
  <pre><code>1  Corolla Toyota  R100,000  1    (user liked)
  2  A3      Audi    R700,000  0    (user did not like)
  </code></pre>
  <p>What Ι have tried is the following without success.</p>
  <pre><code>SELECT
       CarName
     , CarModel
     , CarPrice
     , (
          SELECT COUNT(*)
          FROM tblLikes
          WHERE
                  userId = @userId
              AND CarId = @CarID
      ) as Likes
  FROM tblCars
  
  SELECT COUNT(*)
  FROM tblLikes
  WHERE
          userId = @userId
      AND CarId = @CarID 
  </code></pre>
  <p>Return <code>1</code> if the record exist and <code>0</code> if it does not.</p>