gpt4 book ai didi

mysql - 如何在我的 Codeigniter 模型中使用 SQL LEFT JOIN

转载 作者:行者123 更新时间:2023-11-29 19:19:17 26 4
gpt4 key购买 nike

我在 Codeigniter 模型中使用 LEFT JOIN 进行查询。当我添加 LEFT JOIN 时,我的网页无法正常工作,如下所示

The localhost page isn’t working

localhost is currently unable to handle this request. HTTP ERROR 500

这是我的查询。我添加了 LEFT JOIN(未工作阶段)。我做错了什么?请指导我。我是菜鸟。

$sql = "
SELECT eu.user_id as user_id, DATE_FORMAT(eu.interview_plan_date, '%Y-%m-%d') as plan_date, DATE_FORMAT(eu.interview_plan_date, '%H:%i:%s') as start_time, DATE_FORMAT(DATE_ADD(eu.interview_plan_date, INTERVAL 1 HOUR), '%H:%i:%s') as end_time, count(1) AS cnt
FROM `entry_user_tbl` eu
LEFT JOIN m_admin ma
ON ma.admin_id = eu.interview_plan_staff
WHERE delete_flg = 0
AND interview_plan_date LIKE '$year-$month%'
AND CASE
WHEN (SELECT admin_flg FROM m_admin WHERE admin_id = {$login_id} AND delete_flg=0) = 0 THEN eu.interview_plan_staff = {$login_id}
WHEN {$id} <> 0 THEN eu.interview_plan_staff = {$id}
ELSE TRUE
END
GROUP BY DATE_FORMAT(interview_plan_date, '%Y%m%d')
";

最佳答案

如果是数据库错误,您可能首先打开显示错误,在 Codeigniter 中,您可以通过编辑 index.php 页面并将环境更改为开发来实现

 define('ENVIRONMENT', 'development');

关于mysql - 如何在我的 Codeigniter 模型中使用 SQL LEFT JOIN,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42526604/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com