| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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? |
|
#2
|
|||
|
|||
|
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 |
![]() |
| Viewing: Tutorialized Forums > Desktop Programming > Visual C > complex query help plz |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|