8
I have 4 tables :
Lojas(nomeLoja, *IDloja*, morada, telefone, email)
Bancos(nomeBanco, *IDbanco*, morada)
PlanoContas(*conta*, descricao)
Gestao(NIB, nConta, conta1, conta2, IDloja, IDbanco, *IDgestao*)
conta1 and conta2 are foreign keys to PlanoContas, IDloja foreign key from Lojas and IDbanco foreign key from Bancos.
How can I get a similar output to this:
IDgestao | NIB | nconta | nomeBanco | nomeLoja | descricao_conta1 | descricao_conta2
Idloja and Idbancos are not primary keys in the Management table, they are only in the Banks and Stores table, respectively... I had never done so many joins simultaneously... Once again thank you!
– Pats
@user8539 Oh yeah, it went unnoticed that the same column name existed in the two tables... I removed the comment.
– mgibsonbr
@mgibsonbr the word
aswould not be necessary in theSELECTunless you want to name the column differently. For example,SELECT g.IDgestao AS Digestion. By default, Sql Server uses the column name. Also some columns may have theASwhile others may be without.– brazilianldsjaguar