Querying within the results of a previous query?

Reply

Join Date: Mar 2005
Posts: 2
Reputation: Serp is an unknown quantity at this point 
Solved Threads: 0
Serp Serp is offline Offline
Newbie Poster

Querying within the results of a previous query?

 
0
  #1
Mar 8th, 2005
I'm trying to figure out if this is possible, and cannot find any information about it.

Specifically what I want to do, for example, is allow a web-based user to search for a particular value in one field the first time around. If that returns an overwhelming number of results, I'd like for them to be able to search from within the results of the first query.

I suppose I could have the prior query statement POSTed with the results and nest a bunch of statements, but this seems like it could get really ugly in a hurry. :eek:

Any ideas?
Reply With Quote Quick reply to this message  
Join Date: Nov 2003
Posts: 781
Reputation: Zachery has a spectacular aura about Zachery has a spectacular aura about 
Solved Threads: 21
Team Colleague
Zachery's Avatar
Zachery Zachery is offline Offline
The Geek Father

Re: Querying within the results of a previous query?

 
0
  #2
Mar 8th, 2005
I believe within MySQL 4.1 it supports subqueries.. if thats what your looking for.
Firefox: no, its not the end all solution, it has its own issues and in time it will be just as insecure as IE, when its hit Firefox 6, if it makes it that far. Oh, and AOL pays for it, incase you didn't know.

Microsoft & Windows: If you hate it so much, move to linux, or bsd, or anything else, stop complaning and move on.
Good starting places: Gentoo Novell SUSE Fedora Core Apple
Reply With Quote Quick reply to this message  
Join Date: Mar 2005
Posts: 2
Reputation: Serp is an unknown quantity at this point 
Solved Threads: 0
Serp Serp is offline Offline
Newbie Poster

Re: Querying within the results of a previous query?

 
0
  #3
Mar 9th, 2005
Hmm, no, a subquery is just a one-time thing, too. I'm talking about subsequent calls to the mysql_query() function.

For example, let's say I have a database with tons of records. Here's the first query, which returns thousands of results:

$query="SELECT * FROM sometable WHERE [some condition]";
$result=mysql_query($query);


[at this point, code execution has stopped and the user is on a different page. The user decides to narrow the search, so I'd like to know if there is something akin to the following]

$query2="SELECT * FROM $result where [condition2]";
$result2=mysql_query($query2);


Where $result is a pointer to a table in memory containing the rows that were pulled in the first query.
Reply With Quote Quick reply to this message  
Join Date: Mar 2005
Posts: 48
Reputation: RamiroS is an unknown quantity at this point 
Solved Threads: 0
RamiroS's Avatar
RamiroS RamiroS is offline Offline
Light Poster

Re: Querying within the results of a previous query?

 
0
  #4
Mar 10th, 2005
Mmmm... maybe creating a temporary table with the results of the first query but that will kill performance. In my opinion it is better to create a seach form that "remembers" the values and then the client can always have that reference and change the options to narrow the search.
Reply With Quote Quick reply to this message  
Join Date: Mar 2005
Posts: 1
Reputation: edshuck is an unknown quantity at this point 
Solved Threads: 0
edshuck edshuck is offline Offline
Newbie Poster

Re: Querying within the results of a previous query?

 
0
  #5
Mar 12th, 2005
My site is a community (neighborhood) site and there are all manner of products available at shops. This is my category area.

I do this:

super category >> many to many >> category >> many to many >> shop.

I start with a super category (say dining). Click it and the many to many has dining pointing to Chinese, Italian, Catering and so on. This is displayed. Then the viewer selects the specific category and then the full select statement is put into effect.

Hope this helps.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC