| | |
Querying within the results of a previous query?
Please support our MySQL advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Mar 2005
Posts: 2
Reputation:
Solved Threads: 0
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?
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?
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
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
•
•
Join Date: Mar 2005
Posts: 2
Reputation:
Solved Threads: 0
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.
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.
•
•
Join Date: Mar 2005
Posts: 1
Reputation:
Solved Threads: 0
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.
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.
![]() |
Similar Threads
- test mysql query for no results (PHP)
- Clearing The Contents Of A Datagridview (VB.NET)
- How to change Yes/No (True/False) results from SQL query to checkboxes in DataGrid (VB.NET)
- Populating an array with results from a mysql query... (PHP)
- FILTER QUERY results on a FORM? (Visual Basic 4 / 5 / 6)
Other Threads in the MySQL Forum
- Previous Thread: MySQL. Very much a beginner
- Next Thread: Changing Websites
| Thread Tools | Search this Thread |
agplv3 alfresco amazon api artisticlicense aws bizspark breathalyzer camparingtocolumns changingprices cmg communityjournalism contentmanagement contractors copyright count court crm database design developer development distinct drupal dui ec2 email enterprise eudora facebook form foss gartner gnu government gpl greenit groklaw groupware hiring hyperic images innerjoins insert ip joebrockmeier join journalism keyword keywords kickfire laptop legal license licensing linux maintenance mariadb matchingcolumns metron micromanage microsoft microsoftexchange mindtouch montywidenius mozilla multiple music mysql mysqlcolumnupdating mysqldatetimeordermax() mysqlindex mysqlinternalqueries mysqlquery mysqlsearch news open-xchange opendatabasealliance opengovernment opensource oracle penelope php priceupdating query referencedesign reorderingcolumns saas select sharepoint simpledb sourcecode spotify sql sugarcrm syntax techsupport thunderbird transparency virtualization





