Postgresql get references from a dictionary
<p>I'm trying to build a request to get the data from a table, but some of those columns have foreign keys I would like to replace by the associated keyword in one request.</p>

<p>Basically there's </p>

<p>table A with column 1:PKA-ID and column 2:name.
table B with column 1:PKB-ID, column 2:FKA-ID, column 3:amount.</p>

<p>I want to get all the lines in table B but with all foreign keys replaced by the associated names in table A.</p>

<p>I started building a request with a subrequest + alias to get that, but ofc I have more than one result per subrequest, yet I can't find a way to link that subrequest to the ID of table B [might be exhausted, dumb or both] from the main request. I did something like that:</p>

<pre><code>SELECT (SELECT "NAME" FROM A JOIN B ON ID = FKA-ID) AS name, amount FROM TABLEB;
</code></pre>

<p>it feels so simple of a request yet...</p>