In PHP MySQL how to sum or not sum multiple columns? I have three tables this is my codes:

&lt;table border='1'&gt;
        &lt;tr&gt;
        &lt;th&gt;Subject&lt;/th&gt;
        &lt;th&gt;Mark1&lt;/th&gt;
        &lt;th&gt;Mark2&lt;/th&gt;
        &lt;th&gt;Mark3&lt;/th&gt;
        &lt;th&gt;Sum Marks&lt;/th&gt;
        &lt;/tr&gt;

&lt;?php
    $query2 = "SELECT  students_info.s_name, subjects.subject, marks.*
            FROM  subjects
            RIGHT JOIN  (students_info
            RIGHT JOIN  marks  ON students_info.s_id = marks.s_id
                )  ON subjects.sub_id = marks.sub_id
            WHERE  students_info.s_id = '".$s_id."'";

    $result2=mysqli_query($link,$query2) OR die(mysqli_error($link));   

        while ($row=mysqli_fetch_array($result2))
        {
 ?&gt;
        &lt;tr&gt;
            &lt;td&gt;&lt;?php echo $row['subject'];?&gt;&lt;/td&gt;
            &lt;td&gt;&lt;?php echo $row['n1'];?&gt;&lt;/td&gt;
            &lt;td&gt;&lt;?php echo $row['n2'];?&gt;&lt;/td&gt;
            &lt;td&gt;&lt;?php echo $row['n3'];?&gt;&lt;/td&gt;
            &lt;td&gt;&lt;?php echo $row['n1']+$row['n2']+$row['n3'];?&gt;&lt;/td&gt;
        &lt;/tr&gt;
&lt;?php
        }
?&gt;
        &lt;/table&gt;
 &lt;?php
}
?&gt;


Output my codes:



I want when each mark form(mark1,mark2,mark3) for every subject less than 49 the sum operation not work in the cell sum marks appear empty value or empty cell,
Please review my code and give me a help, to do work this code.
Could add them up in SQL by reverting to 0 for NULL columns like:

SELECT students_info.s_name, subjects.subject, marks.*, 
       COALESCE(marks.n1, 0) + COALESCE(marks.n2, 0) +COALESCE(marks.n3, 0) as  sum_marks
FROM ....