Optimize Query Output

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

 



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:

+-------+-------------+-------------+-----------+---------+
| AttID | SessionDate | LastName    | FirstName | Present |
+-------+-------------+-------------+-----------+---------+
|     1 | 2004-10-30  | Apple     | Robert  | Yes     |
|    11 | 2004-11-06  | Apple     | Robert  | Yes     |
|    31 | 2004-11-13  | Apple     | Robert  | Yes     |
|     2 | 2004-10-30  | Bravo     | Lisa       | Yes     |
|    32 | 2004-11-13  | Bravo     | Lisa       | Yes     |
|    12 | 2004-11-06  | Bravo     | Lisa       | No      |
|     3 | 2004-10-30  | Beta   | Elaine    | Yes     |
|    13 | 2004-11-06  | Beta   | Elaine    | Yes     |
|    14 | 2004-11-06  | Delta | Alexander | Yes     |
|    35 | 2004-11-13  | Delta | Alexander | Yes     |
....


To have it look like:

+-------------+-----------+-------+-------------+---------+
| LastName    | FirstName | AttID | SessionDate | Present |
+-------------+-----------+-------+-------------+---------+
| 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     |
|               |               |    12|  2004-11-13 | Yes     |
| Beta   | Elaine    |     3 | 2004-10-30  | Yes     |
|          |               |    13|  2004-11-06 | Yes     |
| Delta  | Alexander |    14 | 2004-11-06  | Yes     |
|               |               |    35|  2004-11-13 | Yes     |
.....

Please advise I am running on mySql 4.0

-- 
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