Reputation: 1476
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 active_pairs
and translate the value exchange_id
using the value exchange_long_name
into table exchanges
How this can be implemented using JOIN?
Upvotes: 0
Views: 39
Reputation: 3469
SELECT
active_pairs.exchange_id,
exchanges.exchange_long_name
FROM active_pairs
INNER JOIN exchanges USING (exchange_id)
or if you prefer not to use USING
you can join like this
INNER JOIN exchanges ON exchanges.exchange_id = active_pairs.exchange_id
Please note that your datatypes do not match: active_pairs.exchange_id
is an int
while exchanges.exchange_id
is a bigint
.
Upvotes: 1