Rails - PSQL command line query

642 Views Asked by At

I'm trying to make an app in Rails 4 using psql database.

I've created three models for Project, Scope and Background.

The relationships between them are:

Project has one Scope Scope has one Background, and belongs to Project Background belongs to Scope

I can't figure out how to read the psql documentation. I have connected to the database and now want to search for background based on the project id.

My problems are:

  1. I only know how to run one search in psql - that is SELECT * FROM "backgrounds"; I want to know how to search for a specific record in the background table

  2. I don't have a project_id foreign key in my background table. I have a scope_id foreign key. However, I want to search for the project's background.

How do I search in psql, in the command line, for background, where project id = 5?

Thank you

0

There are 0 best solutions below