4

For example, assuming that table A is in database example and table B is in database postgres, how to perform the following query on the two tables?:

SELECT
 A.date,
 A.name,
 B.date,
 B.name
FROM A
INNER JOIN B ON A.name = B.name;

enter image description here

Greg
  • 8,175
  • 16
  • 72
  • 125
  • Your previous answer was correct, the linked question is about two databases which are located on different postgres servers, whereas your answer was for two databases in the same postgres server – Greg Nov 14 '18 at 02:48
  • Yes syntax correct but it cannot produce because `foreign key` cannot connect to other database.. `Postgresql` cannot do Query joining on `Across Database`.. – dwir182 Nov 14 '18 at 02:54
  • @Greg: it doesn't matter if the database are on the same server or different servers. In both cases you would use a foreign data wrapper: https://stackoverflow.com/a/36904631 –  Nov 14 '18 at 06:35
  • allow me to add useful references for any reader: https://stackoverflow.com/questions/4678862/joining-results-from-two-separate-databases and https://stackoverflow.com/questions/29900748/how-to-connect-to-localhost-with-postgres-fdw – Victor Mar 14 '19 at 17:36

0 Answers0