I am trying to use join in the Oracle query but I am not sure how can return all records with or without that join condition. Below is the query
Select req.barcode,contact.barcode,inst.barcode from entity_view req
join entity_association_view assreq ON assreq.entity_id_1 = req.entity_id
join entity_view contact on assreq.entity_id_2 = contact.entity_id and contact.entity_type_name = 'CONTACT'
join entity_association_view assins ON assins.entity_id_2 = contact.entity_id
join entity_view inst on assins.entity_id_1 = inst.entity_id and inst.entity_type_name = 'INSTITUTION'
where req.entity_type_name = 'REQUEST'
Here it returns Requests which has only the contacts. But I want the Requests that without contacts as well. I am not familiar with sub queries should I use that here to get all the records with or without contact
I used left join as well but it is bringing the records like
Select distinct req.barcode,contact.barcode,inst.barcode from entity_view req
left join entity_association_view assreq ON assreq.entity_id_1 = req.entity_id
left join entity_view contact on assreq.entity_id_2 = contact.entity_id and contact.entity_type_name = 'CONTACT'
left join entity_association_view assins ON assins.entity_id_2 = contact.entity_id
left join entity_view inst on assins.entity_id_1 = inst.entity_id and inst.entity_type_name = 'INSTITUTION'
where req.entity_type_name = 'REQUEST' and req.barcode = 'GET0127' order by req.barcode