内部联接不适用于PDO和fetch assoc

For my news en post comment system I can't get the query get results from 2 tables (tbl_news and tbl_comments). In another program I made with mysqli the inner join worked but now this time with PDO I can't get it to work.

This is my code:

$newsQuery = $db->prepare("SELECT * 
                           FROM tbl_news 
                           INNER JOIN tbl_comments ON tbl_news.news_id = tbl_comments.news_id
                           ORDER BY news_id DESC 
                           LIMIT 5");

$newsQuery -> execute();

while($newsFetch = $newsQuery->fetch(PDO::FETCH_OBJ)) {

echo "<div class='news-post'><h3 class='post-title'>" . $newsFetch->title . "</h3>
        <p style='float:left'>By: <span class='post-author'>" . $newsFetch->author . "</span></p>
        <p style='float:right'>Date: <span class='post-date' style='font-style:italic;'>" . $newsFetch->date . "</span></p>
        <br><p>" . $newsFetch->text . "</p></div>";
        if(isset($_SESSION['user']) && ($newsFetch->comments == '1')) {
            echo "Comments(";
            echo "<div id='commentClick'>Click <a href='#' id='openForm'>here</a> to post a comment</div>";
            echo "<form class='navbar-form' id='commentForm'><input style='margin-right:5px' type='text' size='80%' name='commentText' placeholder='Type your comment here'><input type='submit' class='btn btn-primary btn-xs' value='Send'></form>";
        }elseif(!isset($_SESSION['user']) && ($newsFetch->comments == '1')) {
            echo "Click here to view comments. If you want to post comments please login first";
        }else{
            echo "Comments are disabled for this news item";
        }
}

In the database I have the following values: in tbl_news there is a news_id and in tbl_comments are comment_id, news_id and user_id.

Thanks in advance!

You need to use alias for your database table names, ex:

SELECT n.*, c.* FROM tbl_news n 
INNER JOIN tbl_comments c ON n.news_id = c.news_id 
ORDER BY n.news_id DESC LIMIT 5

Your inner join query should be like this

SELECT Customers.CustomerName, Orders.OrderID
FROM Customers
INNER JOIN Orders
ON Customers.CustomerID=Orders.CustomerID
ORDER BY Customers.CustomerName;

I mean you need to specify the tablename.columnname instead of using all (*)

EDIT

  1052 Column 'news_id' in order clause is ambiguous' 

This error happens when you are joining 2 or more tables in a statement and there are columns among these tables that have the same name and you didn’t prefix the column name with the table name when referencing the column in your statement.