Optimize Query Output
| From: | GH | Date: | Sat, 20 Nov 2004 05:39:36 +0000 |
| Subject: | Optimize Query Output | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-37371@lists.php.net to get a copy of this message | ||
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