1
I have a database with 3 tables, where relationships and attributes are distributed this way: 
Precise Retornar o nome, data de nascimento e número do cartão das pessoas em ordem decrescente pela idade;
But how can I return values between tables that have no relationship? In this case the table pessoas and the table cartoes.
Use the accounts table for the joins, even if you won’t return any of them in the final select.
– Jean Barbosa
select pessoas.nome, pessoas.data, contas.id_conta from pessoas inner join contas on pessoas.id_pessoa = contas.pessoas_id_pessoa;Thus?– Mateus Medeiros
@Your case is solved with a simple
INNER JOIN, has tried to do the followingselect:SELECT pessoa.nome, pessoa.data, cartao.numero FROM pessoas AS pessoa INNER JOIN contas AS conta ON conta.id_conta = pessoa.id_pessoa INNER JOIN cartoes AS cartao ON cartao.id_conta = conta.id_conta– William
worked out, @William, thanks! just a doubt, a user has two cards, but only returned one, will there be some problem?
– Mateus Medeiros
@Mateus-Meros I think the modeling of the tables are not so correct so, see if this example helps you. link
– William
in fact @William, I will take a look at this example and try to apply to my problem, thanks again.
– Mateus Medeiros