Discuss

Join Results of 2 Data Collections

On this page

Intro

Using the Data Transformations options you can easily join the results of two different data sources such as - a database query and an API response, the results of 2 database queries from 2 different databases, or any other array data. In our example we will show you how to join the results of 2 database queries from 2 different databases.

Data Transformation

We have two database queries using two different database connections, so we can't join them using the query builder. We can join them using the Data Transformations available in Server Connect.

Data Sources

This is the first database query:

Screenshot_1|690x429

And this is the second one:

Screenshot_2|690x429

If we run this server action, they return the following data:

Screenshot_3|690x429

The first query returns orders (order ID and product ID) and the second one the product details. We want to join them so that they are returned together as one data source.

Join Data Sources

Add a new step in your API Action:

Screenshot_4|690x429

Open the Data Transformations Category and select Join:

Screenshot_5|690x429

Here we need to select our two data collections. Click the dynamic data picker for the first one:

Screenshot_6|690x429

Select the first query and click the select button:

Screenshot_7|690x429

Do the same for the second data collection:

Screenshot_8|690x429

Select the second query and click the select button:

Screenshot_9|690x429

Now we need to select columns to match them by:

Screenshot_10|690x429

Enter the names of the columns of the first and second collections which you want to match by:

Screenshot_11|690x429

Make sure to enable Output for the join step:

Screenshot_12|690x429

And then disable the output for the two query steps, as we don't need them to be outputted. Save your API Action:

Screenshot_13|690x429

And you can see the results, our two collections are joined:

Screenshot_14|690x429