三個表
Classroom 教室表 欄位clno 是編號
borrow 借用的教室表 clno usedate 借用時間
schedule 課程表 clno weekday星期 period節次
一個空教室查詢陳述句 要從教室表查詢出所有的教室 排除 borrow表中借用的教室和schedule表中有課的教室
我是這么寫的,但是不對,不知道該怎么寫
str="select * from Classroom where clno like '9%' and clno not in" +
"(select s1.weekday,s1.period,b1.usedate from Schedule s1,borrow b1 "+
"where s1.weekday = '"+weekdayStr+"' and s1.period = '"+periodStr+"' and b1.usedate = '"+dateStr+"')";
uj5u.com熱心網友回復:
select * from Classroom as a wherea.clno not in (select b.clno from borrow as b)
and
a.clno not in (select c.clno from schedule as c)
這是最直接簡單的吧
uj5u.com熱心網友回復:
感覺問題沒有問清楚,是要查某一時間段空閑的教室吧?比如:某教室8:00-10:00被借用,14:00-16:00有課,那么10:00-14:00以及16:00-18:00就是你期望的結果嗎?還有,你的借用時間是按節次來的還是按天來的?轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/93784.html
標籤:MySQL
