1SELECT IFNULL(field, 0) AS field FROM products WHERE id = 1
2
3SELECT IFNULL(SUM(field), 0) as field FROM products
1##syntax:
2SELECT IFNULL(col_with_null_value, default_value);
3
4##you can see the result select with the string NA where the document is null:
5SELECT IFNULL(user_document_id, 'NA');