SELECT sm.storemain_id,da.equ_id,da.id_per,sum(store_number) AS store_number ,e.equ_name,p.name_per,p.surname_per,w.typeward_name from tb_storemain as sm left join tb_storedata as da on sm.storemain_id=da.storemain_id left join tb_equ as e on da.equ_id=e.equ_id left join tb_per as p on da.id_per=p.id_per left join tb_typeward as w on da.typeward_id = w.typeward_id where storemain_date between '$date1' and '$date2' and da.id_per='$_SESSION[new_username]' group by da.equ_id