I’m having trouble creating a database and relating 3 tables

Asked

Viewed 48 times

1

I’m having difficulty creating a database and relating 3 tables : return the name and surname of the customer, his neighborhood, and the values of his 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;
  • Your problem is to create or access the information entered in this bank, @Lucasnicolaurochasantos? Because your code is only selecting data that should already be existing, and is not creating the BD. Explain better your goal and what you already have, so that I can help you

  • @Luan Naufal I apologize but the problem is to create a bank(I’m having difficulty creating structure for that select works)

  • What error are you getting when trying to create, @Lucasnicolaurochasantos?

2 answers

3


I made a comment to better understand your goal.

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

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

Also you called the wrong table name Movimentos, and wrote Movimento

I detail better the objective that update the answer!

  • 1

    Luan Naufal thanks for your help ,sorry for not being so clear, for your correction of your select can change my table and helped me a lot.

  • Don’t worry, @Lucasnicolaurochasantos! We’re here to help. Good luck

1

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

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;

Browser other questions tagged

You are not signed in. Login or sign up in order to post.