You are here: Re: Complex select query « All PHP « IT news, forums, messages
Re: Complex select query

Posted by Steve on 10/26/06 13:51

| SELECT r.Room ,
| r.Description
| FROM rooms r ,
| (
| SELECT Room
| COUNT(*) Availability
| FROM bookings
| WHERE Reserved >= ' . $startDate . '
| AND Reserved <= ' . $endDate . '
| GROUP BY Room
| ) b
| WHERE b.Room = r.Room
| AND b.Availability = 0
|

check that! that wouldn't give you what you're expecting...this should:

SELECT Room ,
Description
FROM rooms
WHERE Room NOT IN
(
SELECT Room
FROM bookings
WHERE Reserved >= ' . $startDate . '
AND Reserved <= ' . $endDate . '
)

much better. ;^)

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация