With the default PocketQuery structure, using two or more different datasources within one query is not possible. But there are two ways to work around this.

Option 1: Database view

If both databases are located on the same server, you can probably create a database view from one database to the other. This depends on the type of database you are using. Then within PocketQuery, you can use the connection to the first database and a standard SQL statement to join the data.

Option 2: Nested queries

You can work with nested queries. Execute one query to the first data source and subsequently trigger the execution of a nested query to the second data source. This can be achieved by creating a custom template for the first query and trigger the rendering of the second query/macro within it. You can even use results of the first query to parametrize the second one.

The code snippet you need will look similar to this:

$PocketQuery.renderPocketQueryMacro("queryName", {
    'page': $page,
    'parameters': {'MyParmeter':'someValue'},
    'dynamicload': true

You can finde more details on this and related functions in the documentation about the available Velocity objects and the PocketQuery velocity helper in our Velocity API documentation.