select a.entry_time as media_date,a.particulars as media_particular,a.customer_name as in_cust_name,a.jobcard_no as jobcard_no,a.qty as order_qty,a.jobcard_no as plan_qty, sum(a.jobcard_no) as totalplanqty from jobcard_sublist as a LEFT JOIN media_sub_list as b ON a.jobcard_no=b.jobcard_no where DATE_FORMAT(a.entry_time,'%Y-%m-%d')>='2022-10-10' AND DATE_FORMAT(a.entry_time,'%Y-%m-%d')<='2022-10-10' AND a.jobcard_no='JC-2210-1902' AND b.jobcard_no IS NULL group by a.particulars

 UNION

  select b.media_date as media_date,b.media_particular as media_particular,a.customer_name as in_cust_name,b.jobcard_no as jobcard_no,b.order_qty as order_qty,b.plan_qty as plan_qty, sum(b.plan_qty) as totalplanqty from media_sub_list as b left join jobcard_sublist as a ON a.jobcard_no=b.jobcard_no where DATE_FORMAT(b.media_date,'%Y-%m-%d')>='2022-10-10' AND DATE_FORMAT(b.media_date,'%Y-%m-%d')<='2022-10-10' AND b.jobcard_no='JC-2210-1902' AND b.id!='' group by b.media_particular