473,769 Members | 5,205 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Selecting no records if condition is true

Hi - I have a numebr of rooms, which I am making available.

table: single - has single_id and single_name
rental_single has rental_id, single_id, check_in and check_out

They are linked by single_id.

I want to query so that when given two dates, it will return the
single_id that is free between two dates, which means I need to exclude
a singe_id if it has a linked entrey in the rental_single table, which
has a check_in and check_out date which iverlap with my form entries.

My query so far is:

SELECT DISTINCT single.single_i d
FROM single INNER JOIN rental_single ON single.single_i d =
rental_single.s ingle_id
WHERE ((NOT ((rental_single .check_in) BETWEEN #1/1/2004# AND
#20/2/2004#))
AND
(NOT ((rental_single .check_out) BETWEEN #1/1/2004# AND #20/1/2004#)));
Trouble is, if I have an entry in the rental_single table with a check
in of #12/12/2004# and a check_out of #14/12/2004# and a checkin of
#2/1/2004# and #5/2/2004# it will still show that room linked as being
available - I want to exclude the single_id altogether, if ANY of the
entries in thje linked rental_single room fall within the two dates I am
looking for.

I'd really appreciate any pointers,

Thanks,

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #1
1 1355
It's not really an ASP question but a SQL one....
But

Select * from single where single_id not in
(Select single_id from rental where date......)

try that route...

--
Curt Christianson
Owner/Lead Developer, DF-Software
www.Darkfalz.com
"Mark" <an*******@devd ex.com> wrote in message
news:u$******** ******@TK2MSFTN GP09.phx.gbl...
Hi - I have a numebr of rooms, which I am making available.

table: single - has single_id and single_name
rental_single has rental_id, single_id, check_in and check_out

They are linked by single_id.

I want to query so that when given two dates, it will return the
single_id that is free between two dates, which means I need to exclude
a singe_id if it has a linked entrey in the rental_single table, which
has a check_in and check_out date which iverlap with my form entries.

My query so far is:

SELECT DISTINCT single.single_i d
FROM single INNER JOIN rental_single ON single.single_i d =
rental_single.s ingle_id
WHERE ((NOT ((rental_single .check_in) BETWEEN #1/1/2004# AND
#20/2/2004#))
AND
(NOT ((rental_single .check_out) BETWEEN #1/1/2004# AND #20/1/2004#)));
Trouble is, if I have an entry in the rental_single table with a check
in of #12/12/2004# and a check_out of #14/12/2004# and a checkin of
#2/1/2004# and #5/2/2004# it will still show that room linked as being
available - I want to exclude the single_id altogether, if ANY of the
entries in thje linked rental_single room fall within the two dates I am
looking for.

I'd really appreciate any pointers,

Thanks,

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1915
by: Robert | last post by:
Hi All, I'm trying to solve this for a few days now and I just can't figure it out... I have three tables set up, I'll simplify them for this question: Table 1: HOTELS Columns: HOTEL_ID, HOTEL_NAME Exmple row: 123 || 'Hotel X'
3
12502
by: Stewart | last post by:
Hi all! My (relatively small) database holds data on staff members and the projects (services) that they are assigned to. In my form frmStaff, I have a list of staff members - it is a continuous form. Each staff member is linked to a Service through a many-to-many relationship, using a junction table called jctStaffServices. I would like to place a Combo Box in frmStaff where you can 'filter' staff by the Service (i.e. ServiceName)...
1
2567
by: Ramesh | last post by:
hi, I am selecting fields from three table for manupulating data and i want to display total number of records selected. But i am always getting -1 value, eventhough 1000 of records are selected. Below is my code. here strSelectSQL value is strSelectSQL = "Select emp.Empno, emp.FirstName, emp.LastName, emp.DB, emp.DOJ,emp.Grade,emp.yearofexperience,
3
2905
by: M.L. Abram | last post by:
Hello all, I do not know if this question is regarding table design, queries, or programming. Below, I have given a table design using Access 2003. Fields 'Product' and 'Color' are primary keys and 'Active' is a Boolean data type. What I am trying to accomplish is having only one record selected active out of the 'Product' field for each type. If possible, have the user be able to do this task while viewing the data within a...
2
4992
by: ericv | last post by:
I have 3500 records in a table - each record has a unique value (KEY_ID field), but some records share the same value (in a field called POLE_ID) So, there may be 3 records that have the POLE_ID of 25, 4 records with the POLE_ID of 31, etc. I would like to grab all the records in the table that share POLE_ID's - that is, select out the records where there is more than 1 of the same POLE_ID value. I then want to populate a form using this...
1
3330
by: DonWolfi | last post by:
I am trying to get of our the database of our finance system all records where the the first field is the same and that either comply with condition a or condition b. Example: /<font face='Courier' >field 1 field 2 field 3 field 4< >179000 990001 0 100.00< >179500 100001 TAB123 123.00< >180000 100002 TAB250 250.00<
3
3885
by: John Fairhurst | last post by:
Hi, The following code should select the specified number of records randomly from the database <% .... query = "SELECT FROM " Set RS = Server.CreateObject("ADODB.Recordset")
1
1944
by: RZ15 | last post by:
Hi, I have a form that opens a report. The form allows the user to pick a particular warehouse or supplier and an order to sort by. Here is the code for it: Private Sub cmdOK_Click() Dim strSQL As String If Me.cboSort1 <> "" Then strSQL = strSQL & Me.cboSort1
5
2889
by: megahurtz | last post by:
I need to put together an SQL statement and I can't think of how to make it work properly. The scenario is that I have news items in a database that have a launch time and can optionally have an expire time set. I want to select all records that are above the launch time and below their expire time (if it is set). What I have so far is: $rightnow = mktime(); SELECT * FROM teamshadow_news WHERE (launch_time <= $rightnow AND expire_time =...
6
2357
jinalpatel
by: jinalpatel | last post by:
I am using following code for searching records. 'Purpose: Build up the criteria string form the non-blank search boxes, and apply to the form's Filter. 'Notes: 1. We tack " AND " on the end of each condition so you can easily add more search boxes; _ we remove the trailing " AND " at the end. Dim strWhere As String 'The criteria string. Dim lngLen As...
0
9589
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10222
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9999
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9866
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8876
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7413
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
3967
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3570
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.