473,386 Members | 1,815 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

selecting where falls on all dates....

Hi,

I have a table with availability of rooms which has the
htlrm_id: hotel room id
avl_date: date this room is available
avl_qty: quantity of this room available
avl_rate: rate at which these rooms can be booked

an example of the data in the table is:

htlrm_id avl_date avl_qty avl_rate
2 20031005 14 140
2 20031006 3 20
2 20031007 4 40
5 20031005 1 100
5 20031006 1 100
5 20031007 0 120

My customer wishes to see whats available from 20031005 to 20031007
inclusive -- they just want to book one room.

Hotel room 5 is only available for 2 of those days so I only want to
return the rows for htl_id 2.

Using the statement:
SELECT
`tbl_availability_temp`.`htlrm_id`,
`tbl_availability_temp`.`avl_date`,
`tbl_availability_temp`.`avl_qty`,
`tbl_availability_temp`.`avl_rate`
FROM
`tbl_availability_temp`
WHERE
((`tbl_availability_temp`.`avl_date` BETWEEN '2003-10-05' AND
'2003-10-07') AND
(`tbl_availability_temp`.`avl_qty` > 0))

is bringing back:
htlrm_id avl_date avl_qty avl_rate
2 20031005 14 140
2 20031006 3 20
2 20031007 4 40
5 20031005 1 100
5 20031006 1 100

where I want to return:
htlrm_id avl_date avl_qty avl_rate
2 20031005 14 140
2 20031006 3 20
2 20031007 4 40

I'm working off mysql 3.23.53 --- so can't use nested selects like I
normally would.....

Any suggestions? I'd ideally like to keep it all on one statement...if
possible that is.

I've included the sql to create the tables and data:

CREATE TABLE `tbl_availability_temp` (`htlrm_id` smallint(3) unsigned
NOT NULL default '0',
`avl_date` timestamp(8) NOT NULL,
`avl_qty` tinyint(3) unsigned NOT NULL default '0',
`avl_rate` decimal(4,2) NOT NULL default '0.00',
PRIMARY KEY (`htlrm_id`,`avl_date`),
KEY `htlrm_id` (`htlrm_id`,`avl_date`)
) TYPE=MyISAM;

INSERT INTO `tbl_availability_temp` (`htlrm_id`, `avl_date`,
`avl_qty`, `avl_rate`) VALUES
(2,'2003-10-05',14,140),
(2,'2003-10-06',3,20),
(2,'2003-10-07',4,40),
(5,'2003-10-05',1,100),
(5,'2003-10-06',1,100),
(5,'2003-10-07',0,120);

I'm working with php 4.3.2 and mysql 3.23.53.
Jul 19 '05 #1
0 1659

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

Similar topics

1
by: Mark | last post by:
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...
2
by: Catherine | last post by:
I have a database where in my query I need to be able to locate accounts that show a date greater than 14 days from the current date. How would I structure this to allow for all accounts that over...
1
by: tony_aj_fox | last post by:
Hello! Hope y'all can help me. I've just started to use Access and just putting together some simple asp pages for my band's website. We've got a "latest news" table in our db and I want to...
18
by: dfetrow410 | last post by:
Anyone have some code that will do this? Dave
4
by: GregginOttawa | last post by:
I've been Googling and reading for 5 days now trying to figure out how to write a query that selects records with dates in the current week (Sun to Sat). You'd think it would be remarkably simple...
1
by: vunderusaf | last post by:
I have a listbox on a form that is selecting using named FinalQuery: SELECT ., ., . FROM FinalQuery; Now I have a text field with a date on this form and I'd like to use that date as the...
4
by: Good Man | last post by:
Hi there I have a list of jobs scheduled in a MySQL table, with start dates and end dates, like so: SchedID | JobID | StartDate | EndDate |...
2
by: movieking81 | last post by:
If someone could help me with this, that would be great. I need to select a number of records from an SQL table based on a date range, so I started with this select. <html> <code> resultssql =...
3
by: mankolele | last post by:
Hi all. I am having a tough time trying to find a way I can use to make restrictions to drop dows for dates, like the following dates are invalid and cannot be allowed to select them, April...
5
by: lvjan777 | last post by:
Access 2003 Windows XP Professional I'm trying to open a report that displays all the records that are active during the user selected start and stop dates. I’m having trouble with the syntax...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.