web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / How to do a 1:1 SQL SE...
Power Automate
Unanswered

How to do a 1:1 SQL SELECT join across two SharePoint lists

(0) ShareShare
ReportReport
Posted on by 192

I have searched everywhere for the answer to this requirement and cannot find a match for what must be a common requirement.  This would normally be done using a simple SQL SELECT statement, but this is not supported in Flow ☹

 

I want to do a 1:1 join across two SharePoint lists where the join is the unique column ‘EmployeeEmail’.

 

  • Table1 contains the Employee details – one row per employee
  • Table2 contains a minimum of 1 up to a maximum of 5 employee objectives – one row per employee

I have tried using Get List to load Table1 into an array but have got stuck trying to append the Objectives in Table2 to the end of each row in the array.  Do I need one of the Data Operations actions?

 

The output of this query is going to be fed into the FormsPro Send a Survey action.

 

TIA folks!

Categories:
I have the same question (0)
  • Pstork1 Profile Picture
    69,456 Most Valuable Professional on at

    Run a Get Items for each list and then try using the Union() function.  There is no easy way to do the equivalent of a Join with SharePoint lists.  But I've used Union() to do this in the past if there is a Lookup column in the second list that points back to the first.

  • MrNigel Profile Picture
    192 on at

    Hi Paul,

     

    The challenge is I want to append the output from List2 onto the end of List1 (using 'where list1.email=list2.email' as my join) which is why I was trying arrays.  Union just adds the two lists together.  This is so easy to do using SQL SELECT but there is no SELECT command in the expression builder.  Why not I wonder?

     

    Tks

     

    Nigel

     

  • Pstork1 Profile Picture
    69,456 Most Valuable Professional on at

    If there is a Lookup column in List 2 based on list1.email then union should do what you want it to.  

     

    The reason there is no Select where in Power Automate for SharePoint is that SharePoint isn't a relational database.  Its flat tables.  Select Where works in SQL because SQL is designed to be relational.  SharePoint isn't (other than when you simulate relationships using Lookup columns).

  • MrNigel Profile Picture
    192 on at

    Peter,

     

    There is indeed a Lookup column.  List1 contains all employees and List2 contains their objectives.  When creating a new objective you pick the user email from List1 via a lookup.

     

    What is the syntax for the union expression?  There doesn’t seem to be anything other than the two lists.  Does it magically work out they are joined via the email Lookup column?

     

    Thanks,

     

    Nigel

  • Pstork1 Profile Picture
    69,456 Most Valuable Professional on at

    In my tests, if you do Union(List1, List2) it will automatically match the records from list 2 based on the lookup column.

     

    Your only other choice would be to build an array of objects manually using two Apply to each loops.  The outer loop will go through each entry in List 1 and the inner loop will go through list 2 looking for a matching email.  When it finds it the inner loop will write an entry to the array containing the value from List 1 and list 2 that match.  Its really manual, but it will work.  Just not sure how performant it will be.

  • MrNigel Profile Picture
    192 on at

    This is the Union statement I tested: 

    union(body('Get_items_-_Employee_List'),body('Get_items_-_Objectives_List'))
     
    It just adds ObjectivesList below EmployeeList rsather than 'unioning' them.
     
    I will try the Array suggestion - many thanks for this input it is much appreciated.
     
    Nigel

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 801

#2
Valantis Profile Picture

Valantis 602

#3
Haque Profile Picture

Haque 581

Last 30 days Overall leaderboard