tags:

views:

58

answers:

2

we all know that using a group by we can eliminate extra column but then what if i wanted to group item A together. objects related to item A will be shown under the heading item A. but when i use a group by, it would only show one line of object under item A. please dont ask me use count. i just need to show all the objects related under item A.

example:

item A: apple orange

item B: pear

the objects would be retrived from a database. example of codes would be prefered.(:

output: table format

by year, by type, by batch, by company <--- table name 1997, IT, april, apple.com <---- output of above retrive from db peter gordon <--- student name retrive from db jeremy <--- student name retrive from db

1999, enginerring, april, blinkydotcom regina

A: 

output:
table format

by year, by type, by batch, by company <--- table name
1997, IT, april, apple.com <---- output of above retrive from db
peter gordon <--- student name retrive from db
jeremy <--- student name retrive from db

1999, enginerring, april, blinkydotcom
regina
......

ros
OMG Ponies
A: 

You can use the GROUP_CONCAT() function to group students together into one row, however, that row has to be on the same line as the related data. But when you display it in PHP you can just separate it there.

I tried making a query, but you didn't give much information so it's hard to imagine what you want.

Tor Valamo
i tried using that but no use either. also one line):
ros
You always have to put it on the same line, because that's how relational databases work.
Tor Valamo
what i mean it, it gave only one result.
ros
ah, but you have to group it correctly, by using GROUP BY as well
Tor Valamo