I have a query where I want to fetch all rows where the value in column x is between 400-600.
Including in this I want a matching column value from antoher table.
But I want all 200 rows between 400 and 600 regardless of if the value in the second table column exists for the corresponding column value in the first table.
SELECT h.*, k.customer_id FROM EVENTS h, CUSTOMERS k WHERE k.id = h.ident AND h.eventid BETWEEN 400 AND 600 ORDER BY h.eventid;
This limits the results to where
k.id = h.ident is true. But on false I just want an empty value aswell so that I get all 200 rows.
TL;DR – How can I default to a value if Equal to is
a.b=c.d), instead of filtering out that row.