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
-
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 db1999, enginerring, april, blinkydotcom
regina
......OMG Ponies : You can click the edit link - find your username & flare, now look to the left... - to edit your question (or answer). Some will downvote answers like these because they aren't answers, so I recommend deleting it before that happens now that the text is in the question. -
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.
ros : i tried using that but no use either. also one line):Tor Valamo : You always have to put it on the same line, because that's how relational databases work.ros : what i mean it, it gave only one result.Tor Valamo : ah, but you have to group it correctly, by using GROUP BY as well
0 comments:
Post a Comment