在表格之间选择 [英] Selecting between tables

查看:86
本文介绍了在表格之间选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的大家:

我正在开发用于诊所的预订系统,所以我的问题是我想显示尚未预约的可用医生轮班,患者在特定日期和轮班中检查特定医生的可用性.

我有2个表Booking (ID, DocID, shift_id, Date)Shift table (ID, name, DocID)

我想排除保留的班次,并只显示该医生的可用班次??????

Dear guys:

I am developing a booking system for a clinic, so my problem is that I want to display available doctor shift which are not already reserved, the patient check the availability of a certain doctor in specific date and shift.

I have 2 tables Booking (ID, DocID, shift_id, Date) and Shift table (ID, name, DocID)

i want to exclude the reserved shifts, and display just available shifts for this doctors??????

推荐答案

如果班次表包含所有班次,请执行不在加入/a> [
If the shift table contains all the shift, doing a NOT IN join /a>[^] should give you the results.


select * from Shift where ID not in (select shift_id from Booking) and DocID =<specify id=""> and Date = <specify date="">

</specify></specify>




让我知道是否有任何疑问.

如果解决了您的答案,请标记为解决方案




let me know if any queries.

Mark as solution if its solved your answer


感谢您的帮助,我找到了正确的查询,它是:

Thanx for your help, i found the right query which is:

SELECT        Shift.*
FROM            Shift LEFT OUTER JOIN
                         Booking ON Shift.ID = Booking.shift_id AND Shift.DocID = Booking.DocID
WHERE        (Booking.ID IS NULL) OR
                         (Booking.Date <> @VDate)


这篇关于在表格之间选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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