选择特定日期的可用时隙 [英] Selecting available timeslots for a specific date

查看:100
本文介绍了选择特定日期的可用时隙的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过将时间表表与我的时间表表保持不连接来获取特定日期所有可用时隙的列表.

I am trying to get a list of all available timeslots for a specific date by left joining my timeslot table with me schedule table.

SELECT * 
FROM `timeslots` 
LEFT JOIN schedule ON timeslots.timeslot_id = schedule.schedule_timeslot 
LIMIT 0, 30

这将返回:

我要返回的是后3个字段均为空的所有行.因此,鉴于日期为2011-08-01,我希望返回除08:30-10:30之外的所有时隙.我假设需要某种子查询,但我不知道该怎么做.

What I want returned are all the rows that are null for the last 3 fields. So given the date 2011-08-01 I want all the timeslots returned except for 08:30 - 10:30. I'm assuming some sort of sub-query is needed but I don't know how to go about it.

任何帮助将不胜感激.

推荐答案

尝试以下方法:

SELECT * 
FROM `timeslots` 
LEFT JOIN schedule ON timeslots.timeslot_id = schedule.schedule_timeslot
WHERE  schedule.schedule_id IS NULL or schedule.schedule_date <> '2011-08-01'
LIMIT 0, 30

这篇关于选择特定日期的可用时隙的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆