无法获得自然连接以使用给定的表达式? MySQL的

时间:2018-02-07 07:16:41

标签: mysql

SELECT 
    maker, model
FROM Product NATURAL JOIN 

    (SELECT 
        model
    FROM PC
    WHERE (speed >= 3.0)

    UNION

    SELECT
        model
    FROM Laptop
    WHERE (speed >= 3.0))

PC和笔记本电脑是关系(模型,速度)的表:str,int

产品有关系(制造商,型号):str,int

我想做什么:

https://gyazo.com/2fe0ead81635c0b6feb6074de2566061

1 个答案:

答案 0 :(得分:0)

试试这个:

    SELECT 
        maker, model
    FROM Product AS pd NATURAL JOIN 

        (SELECT 
            model
        FROM PC
        WHERE (speed >= 3.0) 

        UNION

        SELECT
            model
        FROM Laptop
        WHERE (speed >= 3.0) 
        ) as result