SELECT mc.med_idlab , mi.namelab, mu.name ,mi.unitprice ,mc.remain ,mc.med_remainall,mc.date_update
FROM
med_cal mc
INNER JOIN med_items mi ON mi.med_items_id=mc.med_idlab
INNER JOIN med_unit mu ON mu.med_unit_id=mi.idunit
where mc.date_update between '2017-02-08' AND '2017-02-09'
GROUP BY mc.med_idlab
ORDER BY mi.med_items_id ASC
คิวรี่ที่2
SELECT *
FROM med_cal
WHERE date_update BETWEEN DATE_ADD('2017-02-08', INTERVAL -1 MONTH)
AND DATE_ADD('2017-02-09', INTERVAL -1 MONTH)
SELECT mc.med_idlab , mi.namelab, mu.name ,mi.unitprice ,mc.remain ,mc.med_remainall,mc.date_update
FROM
med_cal mc
INNER JOIN med_items mi ON mi.med_items_id=mc.med_idlab
INNER JOIN med_unit mu ON mu.med_unit_id=mi.idunit
where mc.date_update BETWEEN DATE_ADD('2017-02-08', INTERVAL -1 MONTH) AND DATE_ADD('2017-02-09', INTERVAL -1 MONTH)
GROUP BY mc.med_idlab
ORDER BY mi.med_items_id ASC
SELECT mc.med_idlab , mi.namelab, mu.name ,mi.unitprice ,mc.remain ,mc.med_remainall,mc.date_update
FROM
med_cal mc
INNER JOIN med_items mi ON mi.med_items_id=mc.med_idlab
INNER JOIN med_unit mu ON mu.med_unit_id=mi.idunit
LEFT JOIN (
SELECT *
FROM med_cal
WHERE date_update BETWEEN DATE_ADD('2017-02-08', INTERVAL -1 MONTH)
AND DATE_ADD('2017-02-09', INTERVAL -1 MONTH)
) mc_ii ON mc.med_idlab = mc_ii.med_idlab
where mc.date_update between '2017-02-08' AND '2017-02-09'
GROUP BY mc.med_idlab
ORDER BY mi.med_items_id ASC