Multiple JOIN and SELECT Statements from eight tables

Posted by user1486004 on Stack Overflow See other posts from Stack Overflow or by user1486004
Published on 2012-06-27T14:48:19Z Indexed on 2012/06/27 15:16 UTC
Read the original article Hit count: 724

Filed under:
|
|

I am trying to make an SQL statement that takes eight different numbers and searches eight different tables from one database for the corresponding value. I keep getting invalid syntax, but I can't figure out why. Here is my code:

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
);

The %s will be changed to numbers only. The column name in each database is "ID" and "Value". I want to search by "ID" and return "Value". Any help is greatly appreciated.

© Stack Overflow or respective owner

Related posts about mysql

Related posts about sql