dongni8969 2017-01-10 08:30
浏览 26

我可以使用什么技巧将LIMIT应用于多次获取?

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.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 Python输入字符串转化为列表排序具体见图,严格按照输入
    • ¥20 XP系统在重新启动后进不去桌面,一直黑屏。
    • ¥15 opencv图像处理,需要四个处理结果图
    • ¥15 无线移动边缘计算系统中的系统模型
    • ¥15 深度学习中的画图问题
    • ¥15 java报错:使用mybatis plus查询一个只返回一条数据的sql,却报错返回了1000多条
    • ¥15 Python报错怎么解决
    • ¥15 simulink如何调用DLL文件
    • ¥15 关于用pyqt6的项目开发该怎么把前段后端和业务层分离
    • ¥30 线性代数的问题,我真的忘了线代的知识了