I have one SQL query with INNER JOINS. I need to get all offers from table offers.
Table offers is empty now. But the following query returns one row with NULL field.
Why is it returned? How to fix that? I need to return 0 rows if table is empty.
Query:
select *, SUM(offers.price * announcement_product.amount) AS total, announcements.user_id AS creator_ann, announcements.id AS ann_id, announcements.delivery AS deliveryAnn, announcements.payment AS paymentAnn, SUM(announcement_product.amount) AS amount, announcement_product.name as name_product from `offers` inner join `announcements` on `announcements`.`id` = `offers`.`announcement_id` inner join `announcement_product` on `offers`.`announcement_product_id` = `announcement_product`.`id` inner join `countries` on `countries`.`id` = `announcements`.`country` where `offers`.`user_id` = 1 and `offers`.`status` = 1 and `offers`.`deleted_at` is null