我有以下 3 张桌子。这只是数据的一小部分,我省略了大多数行和其他我不查询的列。如果包含完整的表格会有所帮助,请告诉我,我可以弄清楚如何发布它们。
信息通信
id items_id itemtype value
1735 21 Software 0.0000
1736 22 Software 0.0000
1739 21 Peripheral 151.2500
1741 23 Peripheral 150.5000
1742 24 Peripheral 0.0000
1743 25 Peripheral 0.0000
地点
id name
34 Anaheim
35 Kirkland
36 Palm Springs
37 Tacoma
外围设备
id name locations_id
11 Logitech USB Wheel Mouse 0
12 Samsung Slate Dock 17
21 USB Scan Gun with Stand 34
23 USB Scan Gun with Stand 63
24 USB Scan Gun with Stand 45
26 USB Scan Gun with Stand 39
我正在对这些表运行以下查询:
SELECT peripherals.name, infocoms.value, locations.name AS Branch
FROM peripherals
JOIN infocoms ON peripherals.id = infocoms.items_id
JOIN locations ON peripherals.locations_id = locations.id
WHERE (peripherals.name = 'USB Scan Gun with Stand'
AND peripherals.locations_id != '0')
GROUP BY peripherals.id ORDER BY locations.name ASC
我得到了正确的行数,但是该值将所有内容显示为 0.0000,而不是实际数量(151.25 和 150.50)。
任何帮助或见解将不胜感激。谢谢。