0

I have the following databases:

server_a {
    a_t1 (a_t1_a1, a_t1_a2);
    a_t2 (a_t2_a1, a_t2_a2);
}
server_b {
    b_t1 (b_t1_a1, b_t1_a2);
    b_t2 (b_t2_a1, b_t2_a2);
}

attribute 1 = serial not null (primary)
attribute 2 = character varying(50)

I have to Join a table in the first to the second database

Here is the sql i have presumed:

Select * from a_t1 full outer join dblink('dbname=server_b','select * from b_t1') 
where a_t1.a_t1_a1>1

however i am getting this error:

ERROR:  syntax error at or near "where"
LINE 1: ...in dblink('dbname=server_b','select * from b_t1') where a_t1...
                                                             ^
********** Error **********

ERROR: syntax error at or near "where"
SQL state: 42601
Character: 83

1 Answer 1

2

Try like this.

Make alias for remote table and perform the query.

Select * from a_t1 full outer join dblink('dbname=server_b','select * from b_t1')  as tmp_b_t1 ( a1 serial not null (primary) , a2 character varying(50) )
where a_t1.tmp_b_t1>1
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.