简体   繁体   中英

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.

I want the who inner joins in parenthesis to be aliased with io but I'm getting a syntax error:

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'

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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