无法识别的语句类型. (在位置0的"WITH"附近) [英] Unrecognized statement type. (near "WITH" at position 0)

查看:375
本文介绍了无法识别的语句类型. (在位置0的"WITH"附近)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用mysql phpmyadmin,版本10.1.34-maraiDB. 我无法执行以下CTE代码. 代码 我在运行代码时显示错误

I'm using mysql phpmyadmin, version 10.1.34-maraiDB. i cant execute the folling cte code. the code error shown when i run the code

WITH cte (Employee_ID, First_Name, Last_Name,Email, Phone, Hire_Date, 
    Manager_ID, Job_Title) AS
(
    SELECT Employee_ID, First_Name, Last_Name,Email, Phone, Hire_Date, 
        Manager_ID, Job_Title
    FROM employees
)

SELECT * FROM cteEmp;

推荐答案

仅从MariaDB版本10.2.1开始支持WITH公用表表达式子句.从文档:

The WITH common table expression clause is only supported starting with MariaDB version 10.2.1. From the documentation:

公用表表达式WITH是在MariaDB 10.2.1中引入的.

Common Table Expression WITH was introduced in MariaDB 10.2.1.

但是,您可以直接将CTE直接内联到查询中,它应该可以工作.在您的特定情况下,您可以只在CTE内部执行代码:

But, you may simply inline your CTE directly into the query, and it should work. In your particular case, you may just execute the code inside the CTE:

SELECT Employee_ID, First_Name, Last_Name,Email, Phone, Hire_Date,
    Manager_ID, Job_Title
FROM employees;

这篇关于无法识别的语句类型. (在位置0的"WITH"附近)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆