1

含まれているcsvからわかるように、次のレポートの作成に問題があります。クエリで重複が生成されています。見つけたSQLステートメントのバリエーションをたくさん試しましたが、うまくいきませんでした。

プライマリテーブル:tblServers

Server ID,Server name,Hostname,Operating System,Admin Password,Attachments
1,"ESX","ESX",1,"**************","CS6.txt;WUG.docx"
2,"Media","media",2,"**************","Access-Compare-CSV-Tables-Relationship.pl;Updates-WSUS.pdf"
3,"Deploy","deploy",3,"**************","WUG.docx"
5,"Newtest","newtest",2,"************",

二次テーブル:tblSettings

ID,Server ID,Role,Feature,Application,Setting,sValue
1,1,1,,,1,"C:\inetpub"
2,1,1,,,6,"test.com"
3,1,1,,,4,"testuser"
4,1,1,,,5,"testpassword"
5,2,,7,,4,"root"
6,2,,7,,5,"pword"
7,2,,5,,6,"techtools.hopto.org"

3番目の表:tblIP

ID,Sebnet,Last Octect,Description
1,"192.168.0",120,"DRAC"
1,"192.168.0",250,"Giga1"
2,"192.168.31",9,"VMWARE"
1,"192.168.31",250,"Giga2"

クエリ-結果

"Server ID","Server name","Hostname","Operating System","Admin Password","Attachments","Role","Feature","Application","Setting","sValue","IP","Description"
1,"ESX","ESX",1,"**************","CS6 License.txt;WUG.docx",1,,,1,"C:\inetpub","192.168.0.250","Giga1"
1,"ESX","ESX",1,"**************","CS6 License.txt;WUG.docx",1,,,6,"test.com","192.168.0.250","Giga1"
1,"ESX","ESX",1,"**************","CS6 License.txt;WUG.docx",1,,,4,"testuser","192.168.0.250","Giga1"
1,"ESX","ESX",1,"**************","CS6 License.txt;WUG.docx",1,,,5,"testpassword","192.168.0.250","Giga1"
1,"ESX","ESX",1,"**************","CS6 License.txt;WUG.docx",1,,,1,"C:\inetpub","192.168.0.120","DRAC"
1,"ESX","ESX",1,"**************","CS6 License.txt;WUG.docx",1,,,6,"test.com","192.168.0.120","DRAC"
1,"ESX","ESX",1,"**************","CS6 License.txt;WUG.docx",1,,,4,"testuser","192.168.0.120","DRAC"
1,"ESX","ESX",1,"**************","CS6 License.txt;WUG.docx",1,,,5,"testpassword","192.168.0.120","DRAC"
1,"ESX","ESX",1,"**************","CS6 License.txt;WUG.docx",1,,,1,"C:\inetpub","192.168.31.250","Giga2"
1,"ESX","ESX",1,"**************","CS6 License.txt;WUG.docx",1,,,6,"test.com","192.168.31.250","Giga2"
1,"ESX","ESX",1,"**************","CS6 License.txt;WUG.docx",1,,,4,"testuser","192.168.31.250","Giga2"
1,"ESX","ESX",1,"**************","CS6 License.txt;WUG.docx",1,,,5,"testpassword","192.168.31.250","Giga2"
2,"Media","media",2,"**************","**;**",,7,,4,"root","192.168.31.9","VMWARE"
2,"Media","media",2,"**************","Access-Compare-CSV-Tables-Relationship.pl;**",,7,,5,"pword","192.168.31.9","VMWARE"
2,"Media","media",2,"**************","Access-Compare-CSV-Tables-Relationship.pl;**",,5,,6,"**","192.168.31.9","VMWARE"

どんな助けでも大歓迎です

編集:

クエリのSQL

SELECT
  tblServers.[Server ID],
  tblServers.[Server name],
  tblServers.Hostname,
  tblServers.[Operating System],
  tblServers.[Admin Password],
  tblServers.Attachments,
  tblSettings.Role,
  tblSettings.Feature,
  tblSettings.Application,
  tblSettings.Setting,
  tblSettings.sValue,
  [tblIP]![Subnet] & "." & [tblIP]![Last Octect] AS IP,
  tblIP.Description
FROM (tblServers
  LEFT JOIN tblSettings ON tblServers.[Server ID] = tblSettings.[Server ID])
  INNER JOIN tblIP ON tblServers.[Server ID] = tblIP.[Server ID]
;
4

1 に答える 1

0

これはSelect Distinct便利な場所です。

次のように、クエリにDistinctキーワードを追加するだけで、重複する値を取得できません。

SELECT Distinct tblServers.[Server ID], tblServers.[Server name], tblServers.Hostname, 
    tblServers.[Operating System], tblServers.[Admin Password], tblServers.Attachments,
    tblSettings.Role, tblSettings.Feature, tblSettings.Application, tblSettings.Setting,
    tblSettings.sValue, [tblIP]![Subnet] & "." & [tblIP]![Last Octect] AS IP,
    tblIP.Description
FROM (tblServers 
  LEFT JOIN tblSettings ON tblServers.[Server ID] = tblSettings.[Server ID]) 
  INNER JOIN tblIP ON tblServers.[Server ID] = tblIP.[Server ID];
于 2012-06-15T01:13:44.867 に答える