"Charles Williams" <[EMAIL PROTECTED]> wrote in
message 008801c12588$80bc7960$fe0aa8c0@chucks">news:008801c12588$80bc7960$fe0aa8c0@chucks...
> Hey folks,
>
> if you go to http://www.acnsnet.com/czc/show.php?state=Bayern  You can see
> my problem with this query.  This thing is killin me so if you have any
> ideas just shout.

This looks like a case of poor database design...

If you had a 'cities' table and referred to it from your
'restaurants', 'hotels', and 'clubs' tables, the query
would be obvious.  (It would slightly complicate
the logic for adding restaurants, hotels, and clubs -
but how often do you do that, compared to
querying the database?)

While you're doing that, I would consider having
a 'states' table too - reduce the number of
text comparisons...


Luckily, a stop-gap is available... create and
populate a temporary cities table, and get your
data from that.

CREATE TEMPORARY TABLE cities
    SELECT city FROM restaurant
        WHERE state='Bayern';

INSERT INTO cities
    SELECT city FROM hotels
        WHERE state='Bayern';

INSERT INTO cities
    SELECT city FROM clubs
        WHERE state='Bayern';

SELECT DISTINCT city FROM cities ORDER BY city;

... how's that?



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to