Friends, there is such a request

SELECT `count_lb` + `count_pr` AS `kek` FROM disciplain WHERE `group`='.$value['id'] 

We fold everything up perfectly, but if in one of the tables the table is NULL , then it shows accordingly NULL . Please tell IFNULL how in my case correctly apply the IFNULL function to check empty fields.

  • If the function is found, is it really difficult to see how it is used? IFNULL(count_lb, 0) + IFNULL(count_pr, 0) - teran

1 answer 1

Try using IFNULL

 select 4 + IFNULL(NULL,0); 

i.e

 SELECT IFNULL(`count_lb`,0) + IFNULL(`count_pr`,0) AS `kek` 

see http://rustyrazorblade.com/2006/09/mysql-number-null-null/