cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Delid4ve
Level 10

Join multiple SQL Tables

Want to know if this is possible.
I have 4 related tables in sql that I need to query to return a set of results:
Get rows - job
Get rows - linked_equipment ( job.id=foreignID)
Get rows - equipment (ID in linked_equipment.equipmentID)
Get rows - class_link (foreignID = equipment.id)

I can do the first filter but I know I then need to use compose somehow as I cannot have nested for each loops.

Thanks in advance
4 REPLIES 4
Community Support Team
Community Support Team

Re: Join multiple SQL Tables

Hi @Delid4ve,

 

You could take a try with the Aggregation transformation under SQL Get Rows action, then expand the query with related tables:

Transformation expand

Follow the article above for the parameters.

 

There is a workaround for Apply to each, we could take use of variables, within a Do until, to work with two Get rows action.

For the four, I am not sure if it would work.

I will make some tests on this, there might be some time delay before I could share any results.

 

Regards,

Michael

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
sundayDriver
Level: Powered On

Re: Join multiple SQL Tables

Hi @v-micsh-msft,

I'm trying to apply the same principle but I can't seem to understand how to do this. Could you elaborate with an example and some screenshots from a flow?

Thank you,

Delid4ve
Level 10

Re: Join multiple SQL Tables

I havnt tested this but now im more familiar you should be able to do this:

 

get rows from 1st table, top count 1.

use compose and get the first ID.

now do the for each on the next table using the compose value as the filter on ID.

 

This is what i havent tested but it should work some how i think:

 

Use concat to put the IDs from the for each in a comma seperated string

in the next get rows query -  ID in Or(  Dynamic content string of comma seperated values  ) - youll have to play about with the format, it may be when you create the string have the seperator as: ' or '  so that it formats like  '1' or '2' or '3'

when i get a chance ill have a play.

 

 

HenryADNewComm
Level: Powered On

Re: Join multiple SQL Tables

Flow can also read a view instead of a table. To create a view you need access to the database with SQL Management Studio (free to download from MS). with a few joins you can create the view you need.

Helpful resources

Announcements
firstImage

Incoming: New and improved badges!

Look out for new contribution recognition badges coming SOON!

firstImage

Power Platform Online Conference

Join us for the first ever Power Platform Online Conference!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Solution Authors
Top Kudoed Authors
Users online (4,317)