SQL Select to show all records from two tables

50 views Asked by At

I have a simple question about sql select. I have two tables:

a) (main) TABLE A - with 10.000 regs. and this fields: "id.table-a" | "name.table-a"

b) TABLE B - with 2.000 regs and this fields: "id.table-b" | "address.table-b" | "id_a.table-b"

And I want to show all the main "TABLE A" regs (10.000) with the "address.table-b" information where "id.table-a" and "id2.table-b" was the same value.

I will see the 10.000 regs but only 2.000 of them will show the information of "TABLE-B".

Thanks for your support.

1

There are 1 answers

0
GMB On

And I want to show all the main "TABLE A" regs (10.000) with the "address.table-b" information where "id.table-a" and "id2.table-b" was the same value.

I will see the 10.000 regs but only 2.000 of them will show the information of "TABLE-B".

I think that you want a left join:

select a.*, b.address_table_b
from tablea a
left join tableb b on a.id_table_a = b.id_table_a