Is there a way to query a result set? My query is too slow

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
fatfishmatt
Forum Newbie
Posts: 5
Joined: Thu Aug 25, 2005 9:43 pm

Is there a way to query a result set? My query is too slow

Post by fatfishmatt »

Is there a way with PHP to query a result set rather than query the database, similar to the <cfquery dbtype="queryName"> tag in ColdFusion?

I have a database with around 10,000 records, each record having a country, state, city field etc.

The user selects the country from a drop down list. The code then querys all 10,000 records in the database and returns a result set of records in that country giving the option for the user to now select a state.

The user then selects the state and the code querys 10,000 records again and returns records with the matching country and matching state.

What I'd like to do in the second instance is instead of query the full 10,000 records again on Country & State, is query result set of the first query (which could be as little as 15 or 20 rather than 10,000) on just State.

And again in the third instance I'd like to query the second result set (which could be as little as 5 or 6 records) on City rather than the full 10,000 again on Country, State & City.

Thanks for the help in advance...
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

check if your DBMS supports views. You could also use a temporary table, probably. It's also possible that your table structure isn't optimized for speed, or your server isn't set up correctly.


Moved to Databases.
Post Reply