I created a dummy bank with the following structure:
BelowarealsothenumberedSQLServerscriptsforcreatingthedatabase,ifneeded.
SQL Fiddle
Now, what I want is to make a query where they are shown:
I created a dummy bank with the following structure:
BelowarealsothenumberedSQLServerscriptsforcreatingthedatabase,ifneeded.
SQL Fiddle
Now, what I want is to make a query where they are shown:
If I understand, this is more or less (I hope I have not interpreted anything wrong):
SELECT Titulares_Adicionais.Limite, Titulares_Adicionais.Grau_Parentesco,
Conta.Cod_Titular, Cliente.Nome
FROM Titulares_Adicionais
INNER JOIN Conta ON Titulares_Adicionais.Cod_Conta = Conta.Codigo
INNER JOIN Cliente ON Titulares_Adicionais.Cod_Cli = Cliente.Codigo
WHERE Titulares_Adicionais.Cod_Cli = 5;
See running SQLFiddle .
In the background the first INNER JOIN
is unnecessary there, but I left it if you want to sophisticate and want to get information from it, it's easy. Note that no data is taken from the Conta
table, so it is not necessary.
The second is necessary because it takes Nome
there in the Cliente
table.
The INNER JOIN
or just JOIN
is that it lists the tables you need based on the columns you set.