CREATE
TABLE
a
(id
INT
)
CREATE
TABLE
B
(cid
INT
,createDate DATETIME)
INSERT
INTO
a
SELECT
1
UNION
SELECT
2
INSERT
INTO
b
SELECT
1,
'2016-02-19'
UNION
SELECT
1,
'2016-02-18'
UNION
SELECT
2,
'2016-02-17'
UNION
SELECT
2,
'2016-02-16'
UNION
SELECT
2,
'2016-02-15'
SELECT
*
FROM
a
LEFT
JOIN
(
SELECT
MAX
(createDate)
AS
createDate,cid
FROM
b
GROUP
BY
cid) b1
ON
=