An example:
SELECT p.MaPhieu, md.MaDV, p.MaCB, HoCB, TenCB, GhiChu, mp.MaMP, TenMP, DaNhapLieu, DATE_FORMAT( ThoiDiemTao, '%d/%m/%Y %H:%i' ) AS TDTao, TenDP, TenTGTN, HoChuHo, TenChuHo
FROM phieu p
LEFT JOIN phieu_dp pdp ON ( p.MaPhieu = pdp.MaPhieu )
LEFT JOIN diaphuong dp ON ( pdp.MaDP = dp.MaDP )
LEFT JOIN phieu_tgtn ptg ON ( p.MaPhieu = ptg.MaPhieu )
LEFT JOIN tongiaotn tgtn ON ( ptg.MaTGTN = tgtn.MaTGTN )
LEFT JOIN phieu_ho pho ON ( p.MaPhieu = pho.MaPhieu )
LEFT JOIN ho ON ( pho.MaHo = ho.MaHo ) , mauphieu mp, mp_donviql md, canbo cb
WHERE p.MaMP = mp.MaMP
AND p.MaCB = cb.MaCB
AND mp.MaMP = 'MCX'
AND mp.MaMP = md.MaMP
AND md.MaDV =5
ORDER BY MaPhieu ASC
0 comments:
Post a Comment