Similar SQL queries returning different results...

Posted by Pablo on Stack Overflow See other posts from Stack Overflow or by Pablo
Published on 2010-12-31T21:08:00Z Indexed on 2010/12/31 22:53 UTC
Read the original article Hit count: 165

Filed under:
|
|

Here are the SQL Queries:

$sql1 = "SELECT count(thread) AS total 
          FROM comments
          WHERE thread=1
          AND parent_id=0
          ";

$sql2 = "SELECT count(thread) AS total 
          FROM comments, users 
          WHERE thread=1
          AND parent_id=0
          AND users.user_id=comments.user_id 
          ";

$sql3 = "SELECT comments.*, users.username AS username
        FROM comments, users 
        WHERE thread=1
        AND parent_id=0
        AND users.user_id=comments.user_id 
        ORDER BY date
        LIMIT 10, 5
        ";

My question is why would $sql1 and $sql2 would return two different results?

$sql1 returns 61 rows

$sql2 returns 56 rows

The 5th line in $sql2 is just for testing, is not required, is just a variation of $sql1 which gets the total rows for a pagination.

© Stack Overflow or respective owner

Related posts about sql

Related posts about mysql