0
我有兩個表,其中一個計劃另一個特定時間段的可用約會列表。我把時間基於日期(第一查詢)的一週中的一天子查詢比較不返回結果
select * from store_schedule where schedule_day = DATE_FORMAT('2011-01-17', '%a')
上述工作正常。
我從哪裏獲得任命的全部金額的日期和具體時間
SELECT count(*) from store_appointment a, store_schedule b
where a.store_schedule_id = b.id and apt_date = '2011-01-17'
在我來說,現在我在上2011/01/17在同一時間,這是兩項任命第二查詢準確地返回使用上述。
我在store_schedule中有一個名爲concurrent_times的列來確定有多少約會可以在store_appointment中共享同一個store_schedule_id。以下是我的組合查詢。
select * from store_schedule where
schedule_day = DATE_FORMAT('2011-01-17', '%a') AND
(SELECT count(*) from store_appointment a, store_schedule b
where a.store_schedule_id = b.id
and apt_date = '2011-01-17') < concurrent_appointments
由於某種原因,此查詢返回零結果。任何人都可以看到我做錯了什麼?每個查詢分解工作正常。