跨表查询,用于显示注释和线程名称,同时两个值在不同的表中

I have 2 tables, one for comments and one for the thread. They are both connected with the thread_id which checks what comments belong to what thread. Now I got a profile page and I want to show the comments posted by the user (which already works) and to what thread(column title) each comment belongs to. I am a beginner with cross table queries and I was wondering how I could accomplish this. Here is my code for showing the comments posted by the user:

$sql_result4 = $mysqli2->query("SELECT * FROM comments WHERE username = '".$profileusername."'");
while($postcomments = mysqli_fetch_assoc($sql_result4)){
        echo"<a  href='thread.php?thread_id={$postcomments['comment_id']}'>{$postcomments['comment']}</a></br>";
}

I was thinking about something like this:

$sql_result4 = $mysqli2->query("SELECT * FROM comments WHERE username = '".$profileusername."'");
$sql_result5 = $mysqli2->query("")
while($postthread = mysqli_fetch_assoc($sql_result5){
    while($postcomments = mysqli_fetch_assoc($sql_result4)){
        echo"<a  href='thread.php?thread_id={$postcomments['comment_id']}'>{$postcomments['comment']}</a></br>";
    }
}

but I have no idea what to use for $sql_result5

What should I put as $sql_result5

You can use just 1 query and use left join.

SELECT c.*, t.* FROM comments c 
LEFT JOIN threads t ON t.id = c.thread_id
WHERE c.username = 'username' 

Now you have all data in 1 result.