join - mysql select multiple tables - return results eventhough the other tables is empty -
select * deliveries, remittance
table 'deliveries' has 10 records while table 'remittance' has none. query returns no results. want mysql return 10 records table 'deliveries'. please me.
this sample table
deliveries -> trans_number to
remittance -> trans_number to
try like
select * deliveries left join remittance on remittance.id = deliveries.remittance_id
it bring data deliveries
, matching data remittance
update:
if want show records in case if table has records looking full outer join
but since full outer join
not supported in mysql try query
select * deliveries left join remittance on remittance.id = deliveries.remittance_id union select * deliveries right join remittance on remittance.id = deliveries.remittance_id
Comments
Post a Comment