本文介绍了需要帮助来编写查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在开发酒店网站.
客房预订的概念
用户可以在此页面上预订房间.
RoomDetails表
RoomCategory Roomno
RoomBooking
用户Roomno ArrivalDate DepartDate
现在,我想编写一个查询来获取那些房间,这些房间只有那些在用户选择日期没有预订的房间.
我写这个查询.但没有得到预期的输出.
I am developing a website on hotel.
There is a concept of Room Booking
User can book there room from this page.
RoomDetails table
RoomCategory Roomno
RoomBooking
User Roomno ArrivalDate DepartDate
Now I want to Write a Query to get the those rooms only those are not booked on the date Choose by the user.
I write this Query. but not getting expected output.
"select top " + DropDownList5.SelectedValue + " roomno from roomdetails where roomno not in (select roomno from roombooking where ((ArrivalDate between '"
+ dt1 + "' and '" + dt2 + "') or (DepartureDate between '"
+ dt1 + "' and '" + dt2 + "'))and Category ='"+DropDownList2.SelectedValue+"') and RoomCategory='"+DropDownList2.SelectedValue+"'"
推荐答案
"select
top " + DropDownList5.SelectedValue + " roomno
from roomdetails
where
roomno not in
(
select roomno
from roombooking
where
(
(
'" + dt1 + "' between ArrivalDate and DepartureDate
)
)
and Category ='"+DropDownList2.SelectedValue+"'
)
and RoomCategory='"+DropDownList2.SelectedValue+"'"
这篇关于需要帮助来编写查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!