I am sorry if the question is elementary but I did not find any clear discussion or guide to understand how to run a query in postgresql. So that a pointer to another website would be also useful. Anyhow, I have two tables:
Table 1
id|day|time|lat|lon|
1a|2010-09-12|4:35:04|44.66038|10.74039|
2a|2010-09-12|13:04:38|44.65472|10.76201|
3a|2010-09-12,15:41:55,44.65450|10.76198|
4a|2010-09-12|15:43:54|44.65469|10.76197|
5a|2010-09-12|15:44:26|44.65476|10.76199|
6a|2010-09-12|15:45:40|44.65480|10.76202|
7a|2010-09-18|07:22:00|44.65480|10.76202|
8a|2010-09-18|07:23:57|44.65477|10.76186|
9a|2010-09-18|07:47:32|44.65470|10.76199|
Table 2
id|day|time|lat|lon|depart/arrive
1b|2010-09-12|4:35:04|44.66038|10.74039|D
2b|2010-09-12|15:45:40|44.65480|10.76202|A
3b|2010-09-18|07:47:32|44.65470|10.76199|D
Table 2 has been obtained from table 1 and it includes an additional column: depart/arrive. This column indicates if the coordinate (or row) is the first coordinate of a path (D) or the last coordinate (A).
Using postgres, I would like to use as common field of the two tables "day", "time", "lat", "lon" in order to obtain a new table 3 that includes all the fields of table 1 plus the "depart/arrive" field of table 2.
Table 3
id|day|time|lat|lon|depart/arrive
1a|2010-09-12|4:35:04|44.66038|10.74039|D
2a|2010-09-12|13:04:38|44.65472|10.76201|NULL
3a|2010-09-12,15:41:55,44.65450|10.76198|NULL
4a|2010-09-12|15:43:54|44.65469|10.76197|NULL
5a|2010-09-12|15:44:26|44.65476|10.76199|NULL
6a|2010-09-12|15:45:40|44.65480|10.76202|A
7a|2010-09-18|07:22:00|44.65480|10.76202|NULL
8a|2010-09-18|07:23:57|44.65477|10.76186|NULL
9a|2010-09-18|07:47:32|44.65470|10.76199|D
I thank you in advance.