MySql selecting default value if there are no result?
        Posted  
        
            by Kenan
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Kenan
        
        
        
        Published on 2010-05-27T15:49:26Z
        Indexed on 
            2010/05/27
            15:51 UTC
        
        
        Read the original article
        Hit count: 246
        
mysql
|mysql-query
i'm having 2 tables: members and comments. I select all members, and then join comments. But in comments I'm selecting some SUM of points, and if user never commented, I can't get that user in listing?!
So how to select default value for SUM, or some other solution:
SELECT c.comment_id AS item_id, m.member_id AS member_id, m.avatar, 
            SUM(c.vote_value) AS vote_value, SUM(c.best) AS best, 
            SUM(c.vote_value) + SUM(c.najbolji)*10 AS total
            FROM members m
            LEFT JOIN comments c ON m.member_id = c.author_id
            GROUP BY c.author_id
            ORDER BY m.member_id DESC
            LIMIT {$sql_start}, {$sql_pokazi}
© Stack Overflow or respective owner