简体   繁体   中英

Querying data by joining two tables in two databases

i'm trying to get data from two databases(test1.db,test2.db) which having same table schema as

CREATE TABLE LoginDetails (
    Name varchar(30),
    PassWord varchar(30),
    email varchar(30)
);

How can I get data (email) from these two databases at a time.

I tried this

select
    LoginDetails.Name test1.db LoginDetails
    left join test2.db LoginDetails on LoginDetails.Name = LoginDetails.Name;

but not working Please help to find out solution

Thanks in advance

Are you looking for union all ?

select name, password, email
from test1.db.LoginDetails
union all
select name, password, email
from test2.db.LoginDetails;

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