Reputation: 1476
I use this SQL query to get data:
SELECT *
FROM common.ACTIVE_PAIRS ap
INNER JOIN exchanges ON exchanges.exchange_id = ap.exchange_id
ORDER BY :sort
LIMIT :limit
OFFSET :offset
The issue is that sometimes ap.exchange_id
can be empty and I don't have a row.
Do you know how I can return the result with empty ap.exchange_id
?
Upvotes: 0
Views: 36
Reputation: 311018
This is exactly what outer (or left) joins are for:
SELECT *
FROM common.ACTIVE_PAIRS ap
LEFT JOIN exchanges ON exchanges.exchange_id = ap.exchange_id -- Note the left join
ORDER BY :sort
LIMIT :limit
OFFSET :offset
Upvotes: 2