all groups > sql server (alternate) > november 2005 >
You're in the

sql server (alternate)

group:

Newbie:Not Exists?



Re: Newbie:Not Exists? Jens
11/30/2005 7:40:17 AM
sql server (alternate): Please post some DDL next time, but I don=B4t know If I understood your
questions right:


"AND AvailDayShow !=3D 0" ?

Jens.
Re: Newbie:Not Exists? Jens
11/30/2005 8:12:24 AM
Ok that why posting DDL and sample data is so important if you are
stating a problem in here:

www.aspfaq.com/5006

-jens.
Re: Newbie:Not Exists? Jens
11/30/2005 8:12:30 AM
Ok that why posting DDL and sample data is so important if you are
stating a problem in here:

www.aspfaq.com/5006

-jens.
Newbie:Not Exists? Buzby
11/30/2005 3:07:51 PM
Hi - hope I'm in the right place - I'm having trouble with a sql statement
for a web page using access as the db (explains the date bit!)

I have two tables - RoomTypes and Availability. The query below brings back
the information I need - except I need to filter it one more time and
exclude any room that has a 0 in a field call AvailDayShow (in the
Availability table) in it across a selected date range. (It's basically
looking across a date range and if a room value is 0 for AvailDayShow in
this range the rooms not bookable so don't show it)

SELECT DISTINCT
RoomTypes.RoomID,
RoomTypes.RoomHotelID,
RoomTypes.RoomType,
RoomTypes.RoomCode,
RoomTypes.RoomDescription,
RoomTypes.RoomIncludes,
Availability.*
FROM
(RoomTypes
INNER JOIN Availability ON
RoomTypes.RoomID = Availability.AvailRoomID)

Where (Availability.AvailDate between #12/09/2005# AND #12/13/2005#)

TIA!!
Hope this makes sense!

Buzby

Re: Newbie:Not Exists? Buzby
11/30/2005 3:46:48 PM

[quoted text, click to view]
Please post some DDL next time, but I don´t know If I understood your
questions right:


"AND AvailDayShow != 0" ?

I wish it were that simple! - basically I have returned a set of days in a
block between dates - if there's a 0 in any of these block I want not to
show it - imagine trying to book a room - I for three nights, - it's
available tonight, tommorrow night, but not on the third night so it can't
be booked.

Thanks for the help - much appreciated - just hope I'm making myself clear
(as mud!!)

Re: Newbie:Not Exists? Buzby
11/30/2005 4:58:28 PM

[quoted text, click to view]

I don't thinks thats possible with access. I'll do my best to explain:-

AvailRoom ID=8 AvailDate = 12/09/2005 AvailDayShow=1
AvailRoom ID=8 AvailDate = 12/10/2005 AvailDayShow=1
AvailRoom ID=8 AvailDate = 12/11/2005 AvailDayShow=0
AvailRoom ID=8 AvailDate = 12/12/2005 AvailDayShow=1
AvailRoom ID=8 AvailDate = 12/13/2005 AvailDayShow=1

The room is bookable for any given day if AvailDayShow = 1.

So in this example If I wanted to book 2 nights 12/09 and 12/10 the rooms is
bookable - however, if I wanted to book three nights from 12/09/2005
AvailDayShow = 0 on the 12/11/2005 , so the room is not bookable.

Hope this makes it clearer! (Sorry did say newbie at the start!!)

Re: Newbie:Not Exists? Erland Sommarskog
11/30/2005 10:10:14 PM
Buzby (gb@pumpupthe.net) writes:
[quoted text, click to view]

Add

AND NOT EXISTS
(SELECT *
FROM Availability A2
WHERE A.AvailRoomID = A2.AvailRoomId
AND A2.AvailDate between #12/09/2005# AND #12/13/2005#
AND A2.AvailDayShow = 0)

If this does not work out, please post:

o CREATE TABLE statements for your tables. Don't forget the keys.
o INSERT statements with sample data.
o The desired result given the sample.

And of course, if you post to this group, you will get syntax for SQL
Server, which may or may not work on Access.


--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
Re: Newbie:Not Exists? Buzby
12/1/2005 12:00:00 AM

[quoted text, click to view]

Erland

Thanks so much for the example - I now fully understand it and am away with
it!

Kind regards

Grant

AddThis Social Bookmark Button