Visual C

 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me



Go Back   Tutorialized ForumsDesktop ProgrammingVisual C

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Tutorialized Forums Sponsor:
  #1  
Old April 24th, 2007, 07:17 PM
hola hola is offline
Contributing User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 2 hola User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
complex query help plz

User selects start and end date....from 25 to 27....

+---------+------+-----------+
| day_Num | qty | room_Type |
+---------+------+-----------+
| 25 | 2 | single |
| 25 | 0 | double |
| 25 | 0 | ensuite |
| 26 | 6 | single |
| 26 | 13 | double |
| 26 | 5 | ensuite |
| 27 | 1 | single |
| 27 | 1 | double |
| 27 | 1 | ensuite |
+---------+------+-----------+

room_Type = double and ensuite has ZERO qty....so all the related data with double and ensuite...should not be printed...so the OUTPUT should be:

+---------+------+-----------+
| day_Num | qty | room_Type |
+---------+------+-----------+
| 25 | 2 | single |
| 26 | 6 | single |
| 27 | 1 | single |
+---------+------+-----------+

And from here then... the lowest qty should be printed out, so the FINAL OUTPUT should be:

+---------+------+-----------+
| day_Num | qty | room_Type |
+---------+------+-----------+
| 27 | 1 | single |
+---------+------+-----------+

Anyone know what the query should be?

Reply With Quote
  #2  
Old April 26th, 2007, 05:10 AM
otuatail otuatail is offline
Contributing User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 8 otuatail User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Are you trying to do this. Show me a room that is available between
25th and 27th where room required (in this case) is single and where the qty is lowest.

Confused you do have a single room available on the 25th but are forcing the customer to take the one available on the27th

SELECT * from MyHotel WHERE day <= 25 and day >= 27 and room_type = 'single' ORDER BY qty ASC LIMIT 1

Preceed this first with $Rows = mysql_num_rows($sql); to find if there are any records. Otherwise you
could get an error if you tried to read non exsisting data.

Desmond

Reply With Quote
Reply

Viewing: Tutorialized ForumsDesktop ProgrammingVisual C > complex query help plz


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.

© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap