SELECT A.ID, A.NAME, A.DATE, B.ID, B.FK_ID, B.CONTENT FROM
(SELECT * FROM TA) AS A
INNER JOIN
(SELECT * FROM TB) AS B
INNER JOIN
(SELECT MAX(ID) AS ID, FK_ID FROM TB GROUP BY FK_ID) AS C
ON B.ID = C.ID
ON A.ID = C.FK_ID
休息休息,顺便帮你写了一个,看看是否受用?^_^
补充一下:
你还可以试试下面这两个
SELECT A.ID, A.NAME, A.DATE, B.ID, B.FK_ID, B.CONTENT FROM
(SELECT * FROM TB) AS B
INNER JOIN
(SELECT MAX(ID) AS ID, FK_ID FROM TB GROUP BY FK_ID) AS C
INNER JOIN
(SELECT * FROM TA) AS A
ON A.ID = C.FK_ID
ON B.ID = C.ID
SELECT A.ID, A.NAME, A.DATE, B.ID, B.FK_ID, B.CONTENT FROM
(SELECT MAX(ID) AS ID, FK_ID FROM TB GROUP BY FK_ID) AS C
INNER JOIN
(SELECT * FROM TB) AS B
INNER JOIN
(SELECT * FROM TA) AS A
ON A.ID = B.FK_ID
ON B.ID = C.ID
然后看看谁快谁慢,再分析分析原因,对你自己有好处的