Hi

Im creating a list of tutorials on my website and I want to group them by the designer. Is it possible, to write a MySQL query which will function on a PHP website which prints the designer name once and then lists all of his tutorials underneath... in one query? and then does it for all of the designers listed...

I can do it with multiple queries, but am looking for a faster solution...

Thanks
lworks

Recommended Answers

All 2 Replies

SQL queries only return two-dimensional tables, so if you want to do that, you would have to get the output somewhat like:

+-----------+-----------+
| Designer  | Article   |
+-----------+-----------+
| Designer1 | Article1  |
| Designer1 | Article2  |
| Designer2 | Article1  |
| Designer2 | Article1  |
+-----------+-----------+

If you could arrange it so that the "Designer" in that output was an integer rather than a string, that would be much better. (A lot less wasted resources on repeated data.)

I would probably start by querying for the designer names and their IDs (assuming you assigned each of them a unique ID?), and then query for a list, like that one, using the IDs as the "Designer" column. And then simply match the IDs when I print the list.

Hi

Thanks for the input, Ill probably go with that,

lworks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.