cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
jasmine2020
Microsoft
Microsoft

Extract value from one table if their values match the 2nd table

**Background:**

I have two tables within a CosmosDB database that hold key:value documents within their containers.
T1 and T2


T1

Id: 111
ems_featurecategory: 1234
ems_name: "win"

 

T2

feature_category: "win"
feature_category: "hello"

 

I wish to query cosmosdb so that I:

Return the value from T1 ems_featurecategory key if the ems_name value from T1 matches the feature_category value from T2.

 

**Desired Output:**

So since the ems_name key's value from T1 matches the featurecategory's key's value from T2

ems_name: "win"
featurecategory: "win",

the value that will be returned will be: 1234

 

 

**My approach:**

JOIN the two tables and perform a query such as:

SELECT c.emsfeaturecategory, c.ems_name, f.feature_category
FROM c
JOIN f in c.id
WHERE array_contains(['',''],c.id,true)
AND c.ems_name = featurecategory...

 

I am not sure how to write this query out successfully. Any suggestions or advice is helpful.

 

 

1 REPLY 1
JohnAageAnderse
Memorable Member
Memorable Member

Hello @jasmine2020 

Not really related to Power Automate 🙂 but here goes - I would use an INNER JOIN to get records from T1 which are found in T2 - like this:

SELECT T1.ems_featurecategory, T1.ems_name, T2.feature_category
FROM T1
INNER JOIN T2 ON T1.ems_name = T2.feature_category

Kind regards, John

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Super User 2 - 2022 Congratulations 768x460.png

Welcome Super Users

The Super User program for 2022- Season 2 has kicked off!

Users online (2,777)