Home > Enterprise >  Get list of items if they match a list into another table
Get list of items if they match a list into another table

Time:12-22

I have these 2 tables which store data:

create table exchanges
(
    exchange_long_name  text,
    exchange_id         bigint
);

create table active_pairs
(
    exchange_id           integer
);

I would like to get the list of exchanges if they are present/match the exchange_id into table active_pairs. How this can be implemented using JOIN?

CodePudding user response:

select  distinct exchanges.exchange_id, exchanges.exchange_long_name
from exchanges inner join active_pairs
on exchanges.exchange_id = active_pairs.exchange_id;
  • Related