I am trying to make a query with overlapping dates. My tabel look like this'
Agenda ID DateStart DateEnd
-------------------------------------------------------
1 2012-04-02 08:00:00 2012-04-02 11:30:00
2 2012-04-02 10:00:00 2012-04-02 13:00:00
3 2012-04-02 12:00:00 2012-04-02 15:00:00
This data is for planning activities. You can't plan a activity if the time overlaps. In this case all the times overlap. But he compares it to the one you planned earlier. Say I planned ID 1, so I can't plan ID 2, But I can plan ID 3.
How Can I write A query with php to select the items that overlap. Thank you very much
SELECT
agenda.DateStart,
agenda.DateEnd,
agenda.AgendaID
FROM
AGENDA
WHERE
????
AND
????
select a.DateStart, a.DateEnd, a.AgendaId, b.DateStart, b.DateEnd, b.AgendaId
from agenda a, agenda b
where
a.AgendaId <> b.AgendaId
and b.DateStart>= a.DateStart and
b.DateStart<= a.DateEnd
$query_Orders = "SELECT * FROM AGENDA WHERE fldTime between DateStart and DateENd ";
You can check with the MYSQL BETWEEN
keyword.