Pulling Data from two sources

I have this updateUserFrom where it shows info about a company, the issue is that I need it to pull data from to different sources

The code I have made looks like this;


But I need it to pull from this one as well;


Hello! Welcome to the forums.

Can you provide a bit more context about what you need to do? The updateUserForm has components that need to join data from two sources? A screenshot or two of the form and the queries you are using could be helpful as well.

Sorry, I'm pretty new to Retool but I will try to give more context

I have two tablets, each using different queries but pulling data from the same resource. What I'm trying to achieve is to create a user-form that can update its information when a user is selected.

The issue I'm facing is that the information it needs to display comes from both tablets. Currently, you have to locate the same user in both tablets and select them for all the relevant information to be shown.

I've been attempting to find a solution to make it display all the necessary information with a single click, but I haven't found a solution yet.

This is how the user-form looks

And are the two tables and the code I'm using:

Oh, I see!

This sounds like you want to either use SQL to join your two tables together to access all of the information or have the selected row of one table trigger the selection of the matching user row in the other table. Logically, these are both matching the data based on a key which will then be used to populate the data in your form.

What would the unique key be that would join these two tables? I see there is a User ID field in the second table, does that match info in the first table?

Yes, the user ID matches the info on both tables

To keep it simple and a single click, you'll only want to show one table. The data on that table should be the result of a join between your two data sets on the ID like in this example SQL Query you can use to join the data:

select a.id, a.number1, b.role from {{ table2.data }} a JOIN {{ table1.data }} b on a.id = b.id

You should be explicitly naming the fields you are looking to join during this select clause. After that, you can just use the output to populate your form data based on the selected row.

Hope this helps!

1 Like

Thanks a lot, that worked like a charm !!

1 Like