简体   繁体   中英

Select from psql and mysql with one query

i have strange issue,

i need select from psql and mysql in one query.

I have users in mysql, and for example location in mysql also need get by userId for example orders from psql.

I need all raw datas in one file.

Of course, Excel can concatenate from two files. But that's not cool.

Sample Three table

Users in mysql .

Id, FirstName, LastName, email, LocationId

Location in mysql

Id, City, Address, Zip

And Orders in Psql .

Id, UserId, ItemName, Quantity, Price

I need something like that:

Select u.FirstName, u.LastName, o.Quantity, 
loc.City from Mysql.Users u
join Mysql.Locations loc on loc.Id = u.Id
join Psql.Orders o on o.UserId = u.Id

You can use foreign tables with https://github.com/EnterpriseDB/mysql_fdw and then join them in posstgres

Like it says on the guithub page

MySQL Foreign Data Wrapper for PostgreSQL

This PostgreSQL extension implements a Foreign Data Wrapper (FDW) for MySQL.

Please note that this version of mysql_fdw works with PostgreSQL and EDB Postgres Advanced Server 9.6, 10, 11, 12, 13 and 14.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM