0
votes

I have two tables and I want to get an output from both tables from a single query. Below is the output of each table.

**select email,id  from people;**

        email                |             id
-----------------------------+------------------------------
 [email protected]             |            uid1
 [email protected]             |            uid2

**select user,date  from company;**

        user                 |             date
-----------------------------+------------------------------
 uid1                        |            2021.1.1
 uid2                        |            2021.2.3

I want an output which consists the date and email address. I tried some JOIN queries but didn't work.

id (people table) and user (company table) are equal.

1

1 Answers

0
votes

As you correctly suspected, a JOIN is the way to go:

select p.id, p.email, c.date
from people p
  join company c on c."user" = p.id;