Heyho folks,

I am sitting now for a few weeks on a tricky problem. I don't get it - maybe
anyone of you could give me a hint.

Let's say I have two tables :

Table One has a lot of information about travels, hotels, flights etc.
Table Two has an entry for each hotel and each day where I store information
about price and most important if this hotel is free on this specific day.

Now I want to gather a list of all hotels I could book in a certain
time-range.
For that I need to issue some quite complex query in table One which is not
at all a problem. But now I need to know if all days in my timeframe are
bookable.
The easiest way to do this is to query table Two for the timeframe I am
looking for and issuing a "count()" - and this I compare with the days
needed and - voila I know if this hotel has a free room for each day.

This works - but I do have a serious performance problem here. I need to
issue this second SELECT on my Table Two for each hotel I found in table
one - and as this are easily more than 2000 I get 2000 additional queries.

Now I thought about doing another join on my first select - but the problem
here is, that I get a huge amount of rows then. Quite clear :) - I have a
record for each day in table Two - so I get hotels * days rows - and this
easily exceeds half a million rows and more.

The best solution I am searching for is now a possibility that I get the
count() of rows in tabel Two somehow in my select on table One.

OK maybe it's a little bit confusing :)

I try to resume the problem :

I do a select on table One.
And I need to know the count() of rows in table Two with my ID which I get
from the first select.

I cant do a join as I then get NrofFoundRows in Table One * NrofFoundRows in
Table Two entries.

Any ideas ?

dodger


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to