Database Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesDatabase Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old April 9th, 2003, 08:26 AM
TheIceman5 TheIceman5 is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 114 TheIceman5 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Any way to query a query?

i want to query a query, like i want to make one query and get the result form that query and query the result of that query, is this possible with mysql?
if so, how?

Reply With Quote
  #2  
Old April 9th, 2003, 10:02 AM
xs0 xs0 is offline
Codewalkers Novice (500 - 999 posts)
 
Join Date: Apr 2007
Location: Ljubljana, Slovenia
Posts: 760 xs0 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: Any way to query a query?

Well, since PHP 4.0.x you can use subqueries, you can also make a temporary table, but it's far easiest by just combining the queries with AND:

1st query:
SELECT * FROM table WHERE category_id=213;

2nd query:
SELECT * FROM would_be_results_from_1st_query WHERE price<100;

combined:
SELECT * FROM table WHERE category_id=213 AND price<100;


Reply With Quote
  #3  
Old April 9th, 2003, 10:32 AM
TheIceman5 TheIceman5 is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 114 TheIceman5 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: Any way to query a query?

yeah thats easy, but i have a query that needs to be done in 2 steps in order to come out right or it will give incorrect results, darn complex fricken query involving 4 tables.
I gotta select a whole mass of records with 4 criteria, group them and then sum the results of 14 fields, will take 2 queries or a temp table. I'd rather not use a temp table if i can only query a query somehow.

Reply With Quote
  #4  
Old April 9th, 2003, 10:42 AM
xs0 xs0 is offline
Codewalkers Novice (500 - 999 posts)
 
Join Date: Apr 2007
Location: Ljubljana, Slovenia
Posts: 760 xs0 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: Any way to query a query?

Please post some details (i.e. your table structure and what you're trying to do) Also, how big is the first result set?

Reply With Quote
  #5  
Old April 11th, 2003, 08:18 AM
TheIceman5 TheIceman5 is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 114 TheIceman5 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: Any way to query a query?

think i will just leave it the way it is, it works, but not 100% efficient.
Too hard to post what you want, theres just not enough room in this forum for it and it wont make sense as it will be too scrambled, the tables are massive, got 30-40 columns and returns about varying amount of records from anything from 10 to 300 depending on how many people are in there and then sums them all grouping on id which is the persons name from another table with about 20 columns.
I was just wanting a small example if what im asking was possible so i could port it into my larger scale problem. Thought it was easier than this.
later...

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesDatabase Help > Any way to query a query?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway