I am having difficulty creating a database and relating 3 tables

1

I am having difficulty creating a database and listing 3 tables: return the customer's name and surname, your neighborhood, and the values of your movements, the date ordering the movements for this sql command to work

 SELECT ClienteNome, ClienteSobrenome, ClienteBairro, MovimentoData,MovimentoValor

 FROM Clientes, Contas, Movimentos

 WHERE Clientes.ClienteCodigo=Contas.ClienteCodigo

 AND Contas.ContaNumero=Movimentos.ContaNumero

 ORDER BY MovimentoData desc;
    
asked by anonymous 06.12.2018 / 23:04

2 answers

3

I made a comment to better understand your goal.

But one thing is clear is that you are accessing the fields in the wrong way: You should write

SELECT Cliente.Nome, Cliente.Sobrenome, Cliente.Bairro, Movimentos.Data, Movimentos.Valor

You also called the wrong name from Table Movimentos , and wrote Movimento

I better detail the purpose of updating the answer!

    
06.12.2018 / 23:41
1

Try this way, pay attention to select because the names of the tables in it were written incorrectly.

SELECT Clientes.Nome, Clientes.Sobrenome, Clientes.Bairro, Movimentos.Data, Movimentos.Valor
FROM Clientes, Contas, Movimentos
WHERE Clientes.Codigo = Contas.Codigo
AND Contas.Numero = Movimentos.Numero
ORDER BY Movimento.Data desc;
    
07.12.2018 / 00:02