Get data where SQL tables have matching fields into a table component

I have 2 SQL tables:

One with a list of emails for each employee and total hours worked each day for this email:

abc@gmail.com, 7
def@gmail.com, 6
abc@gmail.com, 8
def@gmail.com, 5

And a table with Employee Information with firstName, lastName, and email

John, Smith, abc@gmail.com
Abby, Adams, def@gmail.com

Right now I have a table component that connects to the first table and displays all the records of employee emails and hours worked every day

I want to add a custom column that displays each employee's first_name + last_name wherever the email in the table component matches the email in the second SQL table.

How would I do this?

You would need to iterate through the result from the first table and trigger the call but what you should really do is write ONE query to get all the information you need in one result set.
Not sure what type of db you are using - so more information is needed

1 Like

I'm using Microsoft SQL Server.

you would have to use a join to get data from table 2 where table 2 email matches the email from the first...

This should be fairly simple to pull together with a simple query. I don't know all of your actual titles, but something like this:

SELECT firstName, lastName, a.email, hoursWorked
FROM EMPLOYEE_INFO_TABLE a
JOIN WORK_HOURS_TABLE b ON a. email = b.email

Then you can connect your table component to this query.

Hope this helps!