Mysql别名内连接链问题

标签 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 别名,但出现语法错误:

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'

最佳答案

看起来您的意思是这样做:

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

关于Mysql别名内连接链问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47715397/

相关文章:

mysql - 每列的 SQL 唯一值

MySql 数据库使用内连接选择计数(列)

MySQL 子查询、别名、表连接查询的计算

mysql - 无效的 DSN : network address not terminated (missing closing brace)

php - 如何创建一个函数来添加现有信息?

mysql - 当我有平局时,对 SQL 查询结果进行排序时出现问题

python - 使用 SQLAlchemy Core 更新连接表

sqlite - SQLite从具有多个条件的内部联接创建 View

MySql - 对多列使用 ALIAS

linux - 将 "man"替换为 "?"