猿问

SQLSTATE[HY000]: 一般错误 Yii2 中正在执行的 SQL

在我将该引用中的查询实现到代码中后,我在 yii2 中出错了


询问 :


public function actionDeleteduplicate($date){

        Yii::$app->db->createCommand("DELETE t1

                                    FROM HrAttLogsFormatted t1

                                    INNER JOIN

                                    (

                                        SELECT FingerId, MIN(CreatedDate) AS MinCreatedDate

                                        FROM HrAttLogsFormatted 

                                        WHERE DateIn = '".$date."' AND Late != ''

                                        GROUP BY FingerId

                                        HAVING COUNT(FingerId) > 1

                                    ) t2

                                        ON t1.FingerId = t2.FingerId AND t1.CreatedDate = t2.MinCreatedDate

        ")->queryAll();


        $this->redirect(['index']);

    }

结果 :


SQLSTATE[HY000]:一般错误正在执行的 SQL 是: DELETE t1 FROM HrAttLogsFormatted t1 INNER JOIN ( SELECT FingerId, MIN(CreatedDate) AS MinCreatedDate FROM HrAttLogsFormatted WHERE DateIn = '2019-05-03' AND Late BY '' GROUP FingerId HAVING COUNT(FingerId) > 1 ) t2 ON t1.FingerId = t2.FingerId AND t1.CreatedDate = t2.MinCreatedDate


有谁知道代码有什么问题?


哔哔one
浏览 447回答 1
1回答
随时随地看视频慕课网APP
我要回答