我正在尝试创建一个 SQL 语句,它采用八个不同的数字并从一个数据库中搜索八个不同的表以获取相应的值。我不断收到无效的语法,但我不知道为什么。这是我的代码:
SELECT cable_length.ID, drawing.ID, optional.ID, output_type.ID, pressure_range.ID, pressure_type.ID, series.ID, termination.ID
FROM
(
SELECT value AS cable_length FROM A1 WHERE A1.id = %s
JOIN SELECT value AS drawing FROM A2 WHERE A2.id = %s,
JOIN SELECT value AS optional FROM A3 WHERE A3.id = %s,
JOIN SELECT value AS output_type FROM A4 WHERE A4.id = %s,
JOIN SELECT value AS pressure_range FROM A5 WHERE A5.id = %s,
JOIN SELECT value AS pressure_type FROM A6 WHERE A6.id = %s,
JOIN SELECT value AS series FROM A7 WHERE A7.id = %s,
JOIN SELECT value AS termination FROM A8 WHERE A8.id = %s
);
%s 将仅更改为数字。每个表中的列名是“ID”和“Value”。我想按“ID”搜索并返回“Value”。表名是 cable_length 等。非常感谢任何帮助。