今天早上让这段代码工作,去吃午饭,现在它没有显示正确的结果。它显示了应该显示的正确数量的行,但所有结果都是第一行的重复。
SELECT
client_main.serial,
client_main.make,
client_main.model,
client_deploy.ticket,
client_deploy.techID,
client_deploy.installDate,
client_deploy.updateDate,
client_main.status,
client_main.type,
client_software.operating,
client_software.operating_license,
client_profile.buildID,
client_profile.department,
client_main.warrentyStart,
client_main.warrentyEnd,
client_hardware.cpu,
client_hardware.memory,
client_hardware.diskSpace1,
client_hardware.diskSpace2,
client_hardware.diskSpace3,
client_software.antivirus,
client_software.antivirus_version,
client_software.office,
client_software.office_license
FROM
client_main,
client_deploy,
client_hardware,
client_network,
client_profile,
client_software
WHERE client_main.id = client_deploy.id
AND client_deploy.id = client_hardware.id
AND client_hardware.id = client_profile.id
AND client_profile.id = client_software.id
更新:
根据指出的错误修复代码。现在查询只显示一个结果。
SELECT client_main.serial, client_main.make, client_main.model, client_deploy.ticket, client_main.status, client_software.operating, client_profile.username, client_hardware.cpu, client_hardware.diskSpace3, client_software.antivirus, client_network.ip
FROM client_main
inner join client_deploy on client_deploy.id = client_main.id
inner join client_hardware on client_hardware.id = client_main.id
inner join client_network on client_network.id = client_main.id
inner join client_profile on client_profile.id = client_main.id
inner join client_software on client_software.id = client_main.id
样本结果:
serial make model ticket status operating username cpu diskSpace3 antivirus ip
123 Delld Lattitude1 654897 2 4 dhenning1 13 13 4 2
解决方案查询:
SELECT client_main.serial, client_deploy.ticket, client_software.operating, client_profile.username, client_hardware.cpu, client_network.ip
FROM client_main
INNER JOIN client_deploy ON client_deploy.id = client_main.id
INNER JOIN client_hardware ON client_hardware.id = client_main.id
INNER JOIN client_profile ON client_profile.id = client_main.id
INNER JOIN client_network ON client_network.id = client_main.id
INNER JOIN client_software ON client_software.id = client_main.id