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:
  #1  
Old May 14th, 2003, 07:56 AM
Damien Damien is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 9 Damien User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
grouping mysql results using common field text

I am trying to output my database in the following format:

A Common Name (field 1):
fields 2-5
fields 2-5
fields 2-5

A Common Name (different to first - field1):
fields 2-5
fields 2-5

etc.

Basically I have a number of details held in my database where they have common field values. At present, when I output things of this type I have to output each row seperately using the while function.

This would give me:

fields 1-5
fields 1-5
fields 1-5

but field 1 is the same each time, so I only want to display it once for all three records.

Do you follow?

Is it possible to do this, and if so how on earth do I go about it?

Thanks in advance for your help.

Reply With Quote
  #2  
Old May 14th, 2003, 01:55 PM
Blindeddie Blindeddie is offline
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: NJ - USA
Posts: 2,152 Blindeddie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 4
RE: grouping mysql results using common field text

the easiest way is to use nested queries...

first select distinct values from field1 then loop through them. execute another query inside that loop that that pulls fields 2-5 where field1 is equal to field1 from the previous query anl loop through those reslts to display them. There is probably a better way to do it, but in a pinch, this is the way to go.

Reply With Quote
  #3  
Old May 14th, 2003, 08:55 PM
Damien Damien is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 9 Damien User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: grouping mysql results using common field text

Thanks! I didn't think of that - seems so obvious now...

If anyone knows of any more efficient solutions to this - or perhaps just alternatives - I'd be interested in hearing them.

Thanks again for your help Blindeddie.

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesDatabase Help > grouping mysql results using common field text


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 4 hosted by Hostway
Stay green...Green IT