Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

194
Visualizações
Get list of APIs using 3 table joins

I have 3 tables from which I would like to get some data:

Main table:

    create table if not exists exchange
    (
        id bigint,
        name varchar(255),
    );
    
    INSERT INTO exchange (id, name) 
    VALUES (1, 'PARIS');

Second table:

    create table exchange_api
    (
        id                           bigint,
        api_name                     varchar(255),
        exchange_id                  bigint
    );

INSERT INTO exchange_api (id, api_name, exchange_id)
   VALUES (8, 'PARIS-API', 5);

Third table:

create table instrument
(
    id               bigint,
    symbol           varchar(255),
    exchange_api_id  bigint
);

INSERT INTO instrument (id, symbol, exchange_api_id)
VALUES (47, 'PARIS-ARD', 8);
INSERT INTO instrument (id, symbol, exchange_api_id)
VALUES (48, 'PARIS-SRD', 8);

I need to map the the tables following way:

First table exchange I want to send param PARIS

and as a result I want to get this result:

PARIS-ARD
PARIS-SRD

How I can get this data using JOIN?

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

Select I.symbol from instrument I 
inner join exchange_api API 
On I.exchange_api_id API.id
Inner JOIN exchange E
ON API.exchange_id = E.id
where E.name = 'PARIS'

If you want pass Pass 'PARIS' as value then it will return

PARIS-ARD
PARIS-SRD

as output

over 4 years ago · Santiago Trujillo Relatório

0

SELECT 
instrument.symbol           
FROM exchange
JOIN exchange_api
ON exchange.id = exchange_api.exchange_id  
JOIN instrument
ON exchange_api.id = instrument.exchange_api_id  
WHERE exchange.name = 'PARIS'

And with ALIAS:

SELECT 
inst.symbol as I         
FROM exchange AS e
JOIN exchange_api AS ea
ON e.id = ea.exchange_id  
JOIN instrument inst
ON ea.id = inst.exchange_api_id  
WHERE e.name = 'PARIS'
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda