Mysql别名是内连接链的问题

时间:2017-12-08 13:30:34

标签: mysql inner-join alias

我有以下查询

select *
from
    reservation r,
    (
        assignment a
        INNER JOIN class_ c ON a.class_id = c.uniqueid
        INNER JOIN scheduling_subpart ss ON c.subpart_id = ss.uniqueid
        INNER JOIN instr_offering_config ioc ON ss.config_id = ioc.uniqueid
    ) as io
where
    io.solution_id in (32931842) and
    io = r.offering_id

注意:solution_id是分配表上的列。

我希望括号中的who内连接用io别名但我得到语法错误:

  

检查与您的MySQL服务器版本相对应的手册,以便在'(32931842)和io = r.offering_id'

中使用“io,io.solution_id”附近使用正确的语法

1 个答案:

答案 0 :(得分:0)

看起来你的意思是:

select *
from
reservation r,
(
    select * from assignment a ///  You missed the  select * from 
    INNER JOIN class_ c ON a.class_id = c.uniqueid
    INNER JOIN scheduling_subpart ss ON c.subpart_id = ss.uniqueid
    INNER JOIN instr_offering_config ioc ON ss.config_id = ioc.uniqueid
) as io
where
io.solution_id in (32931842) and
io = r.offering_id