How to print data from one table, if it does not exist in another table (php mysql) : <p>I have two tables <code>comments</code> and <code>comments_liked</code>. Users (<code>viewer_id</code>) can like comments written by (<code>UID</code>). Comments are stored in the comments table and comments that are liked are stored in the <strong>comments_liked</strong> table <strong>(as shown in the image attached). 
<a href="https://i.stack.imgur.com/byFZP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/byFZP.png" alt="enter image description here"></a>
**What Im trying to do:</strong></p>

<p>When a user that has (<code>viewer_id</code>) as their id, found in the <strong>comments_liked</strong> table, is viewing their profile, they should see any comments that they have liked/given to a user (UID), <strong>Only when the comment does not exist in the comments table where uid = uid</strong></p>

<p>Please don't get confused, as I am not trying to show all comments where uid=uid.</p>

<p><strong>Below is my code in php</strong></p>

<p>please note : if we can not say <code>where comments_liked.uid != comments.uid</code> as that would show all other values in the comments table.</p>

<pre><code>$query = "
    SELECT * FROM comments_liked

    INNER JOIN comments ON uid = comments.uid

    WHERE uid = ? 
    AND viewer_id = ? 
";
</code></pre>

<p>but my code only prints the records where <code>commnets_liked.uid = comments.uid</code> which is the opposite of what I want. </p>

<p>so if I am user 1, I need to see the record from <code>comments_liked</code> where viewer_id = 1, as it does not exist in <code>comments</code> table.</p>

<p>THANKS FOR YOUR HELP!</p>
