How do I select all the records in the table

0

How do I select all the records in the select below:

$select = "SELECT COUNT(1) AS id_mark, SUM(a.rate) AS rate, b.name_mark, b.id 
           FROM tb_comment a, tb_mark b 
           WHERE a.id_mark=b.id AND b.id_category=:id_c 
           GROUP BY a.id_mark, b.name_mark 
           ORDER BY rate DESC 
           LIMIT $start_pg, $amount_pg";

Because in this SELECT you are just selecting 'items' that have some value at 'rate' , you would not be able to select everything and those that have no value show '0' as value?

In the tb_mark table you have all the records * [topics] * and in the tb_comment table you have all the comments records of the topics , and the select is only displaying the records that have some record in the tb_comment table.

    
asked by anonymous 17.12.2015 / 19:45

1 answer

1

So it takes all the rows from the table

SELECT id_mark, COALESCE(a.rate, 0) AS rate, b.name_mark, b.id FROM tb_comment a, tb_mark b WHERE a.id_mark=b.id AND b.id_category=:id_c ORDER BY rate DESC

    
18.12.2015 / 17:36