mysql - 不能在查询中使用with

标签 mysql sql phpmyadmin

我有以下查询:

with current_round as (
select * 
from match_case_1
where round_id = 12696
)
select *
from current_round cr
where
(
    not exists(select * from current_round where gameweek is null)
)
or 
(
    exists(select * from current_round where status = 1) 
    and not exists(select * from current_round where gameweek is not null)
    and cr.status = 1    
)
or 
(
    not exists(select * from current_round where status = 1)
    and not exists(select * from current_round where gameweek is not null)
    and cast(cr.`datetime` as date) = (
        select max(cast(`datetime` as date)) as `date`
        from current_round
        where status = 5 or status = 3
    )
);

这基本上适用于特定条件,请检查 here有关更多详细信息,问题是 PhpMyAdmin 似乎无法识别 with 运算符,事实上我得到:

Unrecognized statement type. (near "with" at position 0)

我能做什么?

最佳答案

您可以尝试以下 -

select * 
    from match_case_1
    where round_id = 12696 and not exists(select * from match_case_1 where gameweek is null)

关于mysql - 不能在查询中使用with,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55415921/

相关文章:

MySql - 索引优化

sql - 如何查询今天的日期和数据前的7天?

mysql - SQL - 'char' auto_increment 问题

mysql - 如何一次更新多个ID

python - sqlobject线程安全

MySQL寻找最相似的用户

phpmyadmin - MYSQL 查询来计算 mysql 服务器中存在的模式数量

phpmyadmin - 有谁知道为什么 XAMPP 的主机名 ec2amaz-1qpqh3j 具有完全权限且没有密码保护?

mysql - 使用 .sql.gz 文件还原数据库时,gunzip 附近的 SQL 语法错误

MySQL 放入重复的 id