我需要查询当前年份与当前年份+ 6个月之间的条件日期
SELECT VOZ.prez_vozac,VOZ.ime_vozac,LOD.naz_lok,LDO.naz_lok,V.datum
FROM voznja AS V
INNER JOIN vozac AS VOZ ON V.sif_vozac = VOZ.sif_vozac
INNER JOIN lokacija AS LOD ON V.sif_lok_od = LOD.sif_lok
INNER JOIN lokacija AS LDO ON V.sif_lok_do = LDO.sif_lok
INNER JOIN vozilo AS VOZI ON V.regbr = VOZI.regbr
INNER JOIN teret AS T ON V.sif_teret = T.sif_teret
WHERE T.tezina <= 5 AND V.datum BETWEEN ***CURENT YEAR*** AND ***CURRENT YEAR + 6 MONTHS ***
答案 0 :(得分:0)
假设你的意思是现在的日期和现在的六个月......
SELECT VOZ.prez_vozac,VOZ.ime_vozac,LOD.naz_lok,LDO.naz_lok,V.datum
FROM voznja AS V
INNER JOIN vozac AS VOZ ON V.sif_vozac = VOZ.sif_vozac
INNER JOIN lokacija AS LOD ON V.sif_lok_od = LOD.sif_lok
INNER JOIN lokacija AS LDO ON V.sif_lok_do = LDO.sif_lok
INNER JOIN vozilo AS VOZI ON V.regbr = VOZI.regbr
INNER JOIN teret AS T ON V.sif_teret = T.sif_teret
WHERE T.tezina <= 5 AND V.datum BETWEEN CURDATE()
AND DATE_ADD(CURDATE(), INTERVAL 6 MONTH)