|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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. |
|
#2
|
|||
|
|||
|
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. |
|
#3
|
|||
|
|||
|
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. |
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Database Help > grouping mysql results using common field text |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|