Let's say I have this table:
Table A:
id name
--- ---
1 John
Table B:
id content Aid Date
--- --- --- ----------
100 abc 1 2017-02-03 11:16:00
101 xyz 1 2017-02-03 11:50:00
I want to join A and B such that the resulting table has only the one row from B with Date = minimum.
My desired output:
id name content
--- --- ------
1 John abc
My failed attempt at joining is giving me (1, John, xyz) row as well:
SELECT A.[id], A.[name], B.[content]
FROM A
LEFT JOIN B
ON A.id = B.Aid
Later I tried doing a WHERE inside join but I'm not able to construct it:
SELECT A.[id], A.[name]
FROM A
LEFT JOIN B
ON A.id = (SELECT Aid FROM B WHERE Date = (SELECT MIN(Date) FROM B
WHERE <no idea where I'm going?>)
Can someone please point me in the right direction?