このクエリ:
select distinct a.id, a.caminho, c.indexObr, d.id, d.tamanho, d.mask, d.idName
from gedaidb.dbo.sistema_Documentos as a
join gedaidb.dbo.sistema_DocType as b on a.idDocType = b.id
join gedaidb.dbo.sistema_DocType_Index as c on b.id = c.docTypeId
join gedaidb.dbo.sistema_Indexes as d on c.indexId = d.id
join gedaidb.dbo.sistema_Indexacao as e on a.id = e.idDocumento
where a.id = 97
この結果セットを返します:
id caminho indexObr id tamanho mask idName
97 C:\Users\Guilherme\Desktop\Guilherme\Tipo 3\SkypeSetup.exe 0 25 10 NULL Numérico
97 C:\Users\Guilherme\Desktop\Guilherme\Tipo 3\SkypeSetup.exe 0 26 10 NULL AlfaNumérico
97 C:\Users\Guilherme\Desktop\Guilherme\Tipo 3\SkypeSetup.exe 1 24 10 NULL Caracter
クエリに e.valor を追加すると、次のようになります。
select distinct a.id, a.caminho, c.indexObr, d.id, d.tamanho, d.mask, d.idName, e.valor
from gedaidb.dbo.sistema_Documentos as a
join gedaidb.dbo.sistema_DocType as b on a.idDocType = b.id
join gedaidb.dbo.sistema_DocType_Index as c on b.id = c.docTypeId
join gedaidb.dbo.sistema_Indexes as d on c.indexId = d.id
join gedaidb.dbo.sistema_Indexacao as e on a.id = e.idDocumento
where a.id = 97
これらの行が返されます: (唯一の余分な列は最後の列、勇気です)
97 C:\Users\Guilherme\Desktop\Guilherme\Tipo 3\SkypeSetup.exe 0 25 10 NULL Numérico 11111
97 C:\Users\Guilherme\Desktop\Guilherme\Tipo 3\SkypeSetup.exe 0 25 10 NULL Numérico aaaa111
97 C:\Users\Guilherme\Desktop\Guilherme\Tipo 3\SkypeSetup.exe 0 25 10 NULL Numérico ccccc
97 C:\Users\Guilherme\Desktop\Guilherme\Tipo 3\SkypeSetup.exe 0 26 10 NULL AlfaNumérico 11111
97 C:\Users\Guilherme\Desktop\Guilherme\Tipo 3\SkypeSetup.exe 0 26 10 NULL AlfaNumérico aaaa111
97 C:\Users\Guilherme\Desktop\Guilherme\Tipo 3\SkypeSetup.exe 0 26 10 NULL AlfaNumérico ccccc
97 C:\Users\Guilherme\Desktop\Guilherme\Tipo 3\SkypeSetup.exe 1 24 10 NULL Caracter 11111
97 C:\Users\Guilherme\Desktop\Guilherme\Tipo 3\SkypeSetup.exe 1 24 10 NULL Caracter aaaa111
97 C:\Users\Guilherme\Desktop\Guilherme\Tipo 3\SkypeSetup.exe 1 24 10 NULL Caracter ccccc
結合されたすべてのテーブルには1対Nの関係があるため、NN関係がないかどうかを知る限り、それらの余分な行を取得するべきではありません
この問題の背後にある理論は何ですか?