Count likes with INNER JOIN [duplicate]

This question already has an answer here:

I am working on a Xamarin.Forms PCL project where users can post and like others posts. I am trying to make it so when getting the posts it counts the likes and also checks if the user liked the post.

I tried the following code but it doesn’t seem to work and returns no results

$sql = "SELECT posts.*,COUNT(L.*) FROM posts AS P INNER JOIN users AS U ON U.id = P.user_id WHERE P.user_id=:userid LEFT JOIN likes AS L ON L.post_id = P.id";
        $results = DB::query($sql, array(':userid' => $target_id));

Count likes with INNER JOIN [duplicate]