SQL Assistance needed for a not so simple query -
i have database customer table , loan table. customer table has 11,000 records. loan table has customer account numbers each loan entry , specific codes type of loan product taken. however, can see, not every customer has taken loan out, table has fewer records customer table. need find way gather customers meet criteria customers (are active example), possibly join (maybe) loan table , return codes specific loan. however, i'd still want customers customers table didn't take loans included in record set.
so, customers active , if there data customer in loan table return in recordset.
i'm unsure how done, assistance appreciated.
you need left join. :
select c.* , l.loan_code customers c left join loans l on c.customer_id = l.customer_id c.is_active true ...
Comments
Post a Comment