Guhh
Guhh

Reputation: 410

Select all from one table and if exist take the more details on another table

I have two different tables, both there is similar unique keys so I can link both using this ID.

On the first table I have 1287 people registered and on the second table I have just 786 people registered.

Then, I want to show 1287 people of the first table and if exist this same ID on the other table 786 show more information about this subscribed..

I don't know if I could explain very well, but I have no idea how start it.

SELECT * FROM oficinas_inscritos, oficina_pesquisa WHERE oficina_pesquisa.cpf = oficinas_inscritos.cpf

Upvotes: 0

Views: 48

Answers (1)

Kickstart
Kickstart

Reputation: 21513

Simple LEFT OUTER JOIN:-

SELECT * 
FROM oficinas_inscritos
LEFT OUTER JOIN oficina_pesquisa 
ON oficina_pesquisa.cpf = oficinas_inscritos.cpf

Upvotes: 1

Related Questions