Hola gspablo...
Si entendí bien cuál es tu problema, esto debería funcionar:
Código MySQL:
Ver originalQuery OK, 0 rows affected (0.10 sec)
-> (30,29,'R_RED_CANAL_05_04.pdf','2004-05-31 11:03:32'),
-> (268,29,'R_GNR_RED_30_01_04.pdf','2004-01-30 16:59:48'),
-> (287,29,'R_DRV_RED_27_02_04.pdf','2004-02-27 10:59:04'),
-> (288,29,'R_RED_CANAL_31_03_04.pdf','2004-03-31 11:00:14'),
-> (289,29,'R_RED_CANAL_30_04_04.pdf','2004-04-30 11:00:37');
Query OK, 5 rows affected (0.05 sec)
+------+-------+--------------------------+---------------------+
| id | idDoc | NombreArchivo | fecha |
+------+-------+--------------------------+---------------------+
| 30 | 29 | R_RED_CANAL_05_04.pdf | 2004-05-31 11:03:32 |
| 268 | 29 | R_GNR_RED_30_01_04.pdf | 2004-01-30 16:59:48 |
| 287 | 29 | R_DRV_RED_27_02_04.pdf | 2004-02-27 10:59:04 |
| 288 | 29 | R_RED_CANAL_31_03_04.pdf | 2004-03-31 11:00:14 |
| 289 | 29 | R_RED_CANAL_30_04_04.pdf | 2004-04-30 11:00:37 |
+------+-------+--------------------------+---------------------+
-> (
-> ) T2
ON T1.idDoc
= T2.idDoc
AND T1.id
= T2.max_id
; +------+-------+--------------------------+---------------------+
| id | idDoc | NombreArchivo | fecha |
+------+-------+--------------------------+---------------------+
| 289 | 29 | R_RED_CANAL_30_04_04.pdf | 2004-04-30 11:00:37 |
+------+-------+--------------------------+---------------------+
Dale un vistazo al script para ver si es lo que necesitas.
Saludos
Leo.