簡體   English   中英

Mysql別名內部聯接鏈問題

[英]Mysql alias the chain of inner joins issue

我有以下查詢

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是分配表上的列。

我希望將括號中的內部連接的對象別名為io,但出現語法錯誤:

檢查與您的MySQL服務器版本相對應的手冊以獲取正確的語法,以在“ as io其中使用(32931842)中的io.solution_id和io = r.offering_id”附近使用

看來您是要這樣做:

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