I am working on two SQL which are similar just difference is in first query stock is calculated between two dates and second query using current date.
PHP:
$sql="select all_dates.value1 as `Date`, sum(coalesce(`Inward(B_Qty)`, '0')) as `Inward`, sum(coalesce(`Outward(B_Qty)`, '0')) as `Outward`
from ( select distinct M_Date as value1 from machine where J_Name = '180MLGMV' and DATE(M_Date) between '2016-06-01' and '2016-06-06'
union select distinct M_Date from machine where Pre_Req = '180MLGMV' and DATE(M_Date) between '2016-06-01' and '2016-06-06' ) as all_dates
left join (select M_Date, sum(A_Prod) AS `Inward(B_Qty)`
from machine where J_Name = '180MLGMV' and DATE(M_Date) between '2016-06-01' and '2016-06-06' group by M_Date)
as g on g.M_Date = all_dates.value1
left join( select M_Date, sum(NoBot) AS `Outward(B_Qty)`
from machine where Pre_req ='180MLGMV' and DATE(M_Date) between '2016-06-01' and '2016-06-06' group by M_Date)
as f on f.M_Date = all_dates.value1 group by all_dates.value1 ;" ;
$sql.="select all_dates.value1 as `Date`, sum(coalesce(`Inward(B_Qty)`, '0')) as `Inward`, sum(coalesce(`Outward(B_Qty)`, '0')) as `Outward`
from ( select distinct M_Date as value1 from machine where J_Name = '180MLGMV' and M_Date='2016-06-07'
union select distinct M_Date from machine where Pre_Req = '180MLGMV' and M_Date='2016-06-07' ) as all_dates
left join (select M_Date, sum(A_Prod) AS `Inward(B_Qty)`
from machine where J_Name = '180MLGMV' and M_Date='2016-06-07' group by M_Date)
as g on g.M_Date = all_dates.value1
left join( select M_Date, sum(NoBot) AS `Outward(B_Qty)`
from machine where Pre_req ='180MLGMV' and M_Date='2016-06-07' group by M_Date)
as f on f.M_Date = all_dates.value1 group by all_dates.value1 ";
$list1=mysqli_multi_query($sql,$con);
while($row_list1=mysql_fetch_array($list1))
{
$b=$b+$row_list1['Inward'];
$c=$c+$row_list1['Outward'];
}
Please suggest how to retrieve the data of Date,Inward and outward of each Query.I mean what should write below the mysqli_multi_query to retrieve the four data.
Thanks in advance.