Re: Optimize Query Output

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



GH wrote:
I have the following query:

SELECT A.`AttID` , S.`SessionDate` , P.LastName, P.FirstName, A.`Present`
FROM `Attendance` A, Sessions S, Participants P
WHERE S.SessionID = A.`Session` AND P.Part_ID = A.`Participant`
GROUP BY P.LastName, P.FirstName, A.Present, A.AttID

I would like to have the output to have the P.LastName and P.FirstName
values only shown once and the rest of the output printed...

So instead of something like:

|     1 | 2004-10-30  | Apple     | Robert  | Yes     |
|    11 | 2004-11-06  | Apple     | Robert  | Yes     |

To have it look like:
>
| Apple     | Robert S. |     1 | 2004-10-30  | Yes     |
|               |               |    11|  2004-11-06 | Yes     |
|               |               |    31|  2004-11-13 | Yes     |
| Bravo     | Luz       |     2 | 2004-10-30  | Yes     |
|              |             |    32|  2004-11-06 | No     |

Your query is never going to look like that. You use PHP to format the result set so it displays how you want it. As you loop through the returned rows, keep track of what the current first and last name are. If they change, then output them, otherwise output a blank cell.


--

---John Holmes...

Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux