I'm new to SQL and trying to find the correct join to use in this situation. Table A contains a series of unique (i.e. no repeats) IDs. Table B contains multiple measurements for each ID, including IDs that don't exist in table A. I need a combined table that contains all the data in table B for the IDs that are in table A.
For example:
A B JOINED:
ID ID | count | date ID | count | date
- -- | ----- | ---- -- | ----- | ----
001 001 | 512 | 01-Aug-2014 001 | 512 | 01-Aug-2014
003 001 | 123 | 08-Aug-2014 001 | 123 | 08-Aug-2014
004 002 | 2325 | 01-Aug-2014 003 | 2325 | 01-Aug-2014
002 | 7653 | 08-Aug-2014 003 | 423 | 08-Aug-2014
003 | 2325 | 01-Aug-2014 004 | 2 | 01-Aug-2014
003 | 423 | 08-Aug-2014 004 | 76 | 08-Aug-2014
004 | 2 | 01-Aug-2014
004 | 76 | 08-Aug-2014
005 | 232 | 01-Aug-2014
005 | 67 | 08-Aug-2014
Now, if I understand joins correctly, a LEFT join on A-B would produce a result that only had one line for each ID, not the multiple lines for each date. A RIGHT join would include all the IDs in B that aren't in A. Is that correct?
So, in summary, how do I get a results table like that shown above?