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 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

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -