mysql - 使用 sql 中的请求不起作用并识别
问题描述
我的请求有问题,请求无法识别 WITH()。我在 Ubuntu 和 MySQL 上工作,我能得到帮助吗?
DB::select(DB::raw("WITH liststudentsoff as (
SELECT tbl_etudiants.*, tbl_cours.idCours FROM dependance_groupes
inner join tbl_etudiants on tbl_etudiants.idStudent = dependance_groupes.studentID
inner join tbl_cours on tbl_cours.groupID = dependance_groupes.groupID
inner join tbl_formations on tbl_formations.idFormation = tbl_cours.formationID
)
SELECT * FROM liststudentsoff
LEFT JOIN tbl_absences ON liststudentsoff.idStudent = tbl_absences.studentID AND liststudentsoff.idCours = tbl_absences.coursID
WHERE liststudentsoff.idCours = ".$request->idCours." and liststudentsoff.formationID = ".$cours->formationID.""));
错误显示:
[previous exception] [object] (PDOException(code: 42000): SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'liststudentsoff as (
SELECT tbl_etudiants.*, tbl_cours.idCours FROM ' at line 1 at /var/www/html/emarge-backoffice/vendor/laravel/framework/src/Illuminate/Database/Connection.php:338)
解决方案
推荐阅读
- android - Gradlew:不支持的major.minor 52.0版
- math - 将 0f 添加到浮点数有什么意义?
- javascript - Expo FileSystem.readAsStringAsync 不等待
- java - 将 if 语句转换为 swicth
- python - 警报弹出异常处理 Python Selenium
- common-lisp - 使用局部变量并在嵌套的 Common Lisp 循环中返回它们
- android - 自定义对话框错误
- asp.net-mvc - 在 MVC 控制器中查询 ID 数组
- sql - 如何在一段时间内选择不同的总列数并按created_at对它们进行分组?
- autodesk-forge - 3DS Max 存档导入翻译失败