Query two databases (both SQL Anywhere 12)

Questions and answers regarding general SQL and backend databases

Query two databases (both SQL Anywhere 12)

Postby huber » Wed Sep 04, 2013 3:18 pm

How can I query two databases? In my case two SQL Anywhere 12 databases. They use the same database server name.

I would like to do something like:
Code: Select all
SELECT onedb.*, otherdb.*
FROM server1.Database1.dbowner.myTable AS onedb
INNER JOIN server2.Database2.dbowner.myTable AS otherdb
   ON onedb.id = otherdb.id
Robert Huber
7r AG, Switzerland
SAN Developer
http://www.seven-r.ch
User avatar
huber
 
Posts: 518
Joined: Mon May 14, 2012 11:31 pm

Re: Query two databases (both SQL Anywhere 12)

Postby rgansevles » Wed Sep 04, 2013 5:31 pm

Robert,

Check on sql anywhere forums if this is possible.

Servoy will only join across databases when they are in the same jdbc connection.
If you want to use server2.Database2.dbowner.myTable in server1 you would need to expose it in server1, possibly as a view.

Rob
Rob Gansevles
Servoy
User avatar
rgansevles
 
Posts: 1927
Joined: Wed Nov 15, 2006 6:17 pm
Location: Amersfoort, NL

Re: Query two databases (both SQL Anywhere 12)

Postby huber » Wed Sep 04, 2013 6:02 pm

Rob

I checked in the SQL Anywhere forum, unfortunatly it's down at the moment. I will try later on of course.
I didn't know two databases can be in the same jdbc connection. Is this possible to use twice the same database server name?
In distributed database environment my asking should be a "normal" requirement, shoudn't it?
Thanks for the hint about the view.

rgansevles wrote:Robert,

Check on sql anywhere forums if this is possible.

Servoy will only join across databases when they are in the same jdbc connection.
If you want to use server2.Database2.dbowner.myTable in server1 you would need to expose it in server1, possibly as a view.

Rob
Robert Huber
7r AG, Switzerland
SAN Developer
http://www.seven-r.ch
User avatar
huber
 
Posts: 518
Joined: Mon May 14, 2012 11:31 pm

Re: Query two databases (both SQL Anywhere 12)

Postby sbutler » Thu Sep 05, 2013 9:31 pm

you can do that in MySQL without any changes. For SQL Anywhere, I think your looking for is called proxy tables, where you create a table in your otherdb that is a proxy to onedb, and then you can join them with a sql query.
Scott Butler
iTech Professionals, Inc.
SAN Partner

Servoy Consulting & Development
Servoy University- Training Videos
Servoy Components- Plugins, Beans, and Web Components
Servoy Guy- Tips & Resources
ServoyForge- Open Source Components
User avatar
sbutler
Servoy Expert
 
Posts: 759
Joined: Sun Jan 08, 2006 7:15 am
Location: Cincinnati, OH

Re: Query two databases (both SQL Anywhere 12)

Postby mboegem » Fri Sep 06, 2013 12:25 am

goldcougar wrote:For SQL Anywhere, I think your looking for is called proxy tables, where you create a table in your otherdb that is a proxy to onedb, and then you can join them with a sql query.

Pretty sure this is the case or at least was back in versions 10/11, don't know if Sybase changed the game in 12.
Marc Boegem
Solutiative / JBS Group, Partner
Servoy Specialist
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image
User avatar
mboegem
 
Posts: 1748
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam


Return to SQL Databases

Who is online

Users browsing this forum: Bing [Bot] and 2 guests