Doubt how to recover data from another table with Postgres

Asked

Viewed 46 times

0

I have two tables: Department with id and name

Telephone contains id_department and extension

I have already registered a department and some extensions where the id_departamento refers to the registered department

In Postgres, how would select for me to get all extensions related to the Department that I registered?

1 answer

1


Select t.ramal from Telefone t 
    join Departamento d on d.id = t.id_departamento
where d.id = {id que vc quer} 

Obs: since id_department is a Foreign key I would change the name to fk_departamento

  • Thank you Arthur, it worked right. Hug

Browser other questions tagged

You are not signed in. Login or sign up in order to post.