简体   繁体   English

Mysql别名内部联接链问题

[英]Mysql alias the chain of inner joins issue

I have the following query 我有以下查询

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

Note: solution_id is column on the assignment table. 注意:solution_id是分配表上的列。

I want the who inner joins in parenthesis to be aliased with io but I'm getting a syntax error: 我希望将括号中的内部连接的对象别名为io,但出现语法错误:

Check the manual that corresponds to your MySQL server version for the right syntax to use near 'as io where io.solution_id in (32931842) and io = r.offering_id' 检查与您的MySQL服务器版本相对应的手册以获取正确的语法,以在“ as io其中使用(32931842)中的io.solution_id和io = r.offering_id”附近使用

It look like you mean to do this: 看来您是要这样做:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM