I don't know if I can do what I expect but hey, at least I can ask you guys...
Here's the thing : I'm building a website with some calendars, and we can add some "dates / rendez vous" on them. For some purpose, I want to get the futur (or actual) closest rendez-vous of each calendars.
I'd like to do it with one query instead of using a loop with one query on each iteration (ie for each calendar), and I want to get only ONE rendez-vous for each calendar and not all the futur ones (which could be... a lot).
So far, I started like that :
SELECT p_id, p_cid, p_start, p_end FROM p WHERE p_end >= :date_of_today
I was thinking about using LIMIT, but I can't see how to put a LIMIT (like 0,1
for each calendar)...
I guess I will have to use a loop but if someone could give me an other solution :)
EDIT
With more informations :
I have a table for calendars, which is like c_id, c_title, c_owner
, and a table for the rendez-vous, which is like p_id, p_cid, p_uid, p_start, p_end
.
The rendez-vous can last more than one day. To be more specific, a "rendez-vous" is at least a day : so p_start
and p_end
are a date/timestamp like dd-mm-yyyy 00:00:00
. They can be equal as they can be two differents days.