gpt4 book ai didi

通过选择不同值插入查询中的 MySQL 语法错误

转载 作者:行者123 更新时间:2023-11-29 20:51:03 25 4
gpt4 key购买 nike

我的查询显示错误(预期表达式接近 DISTINCT),我不知道如何解决它,如果我删除第一个 INSERT 查询行,值选择正确,如果我添加插入它显示错误,任何帮助都可以很有用,提前致谢。

INSERT INTO normal_days (user_id, department_id,designation_id,date_cur,clock_in,clock_out)
SELECT DISTINCT clo.user_id, design.department_id , uses.designation_id, clo.date,clo.clock_in, clo.clock_out
FROM clock clo
INNER JOIN holidays AS hol ON hol.date != clo.date
INNER JOIN users AS uses ON clo.user_id = uses.id
INNER JOIN designations AS design ON design.id = uses.designation_id
WHERE date(clo.created_at) = "2016-06-23"
AND TIMESTAMPDIFF(second,clo.clock_in, clo.clock_out) = 28800
AND !(DAYOFWEEK(clo.date)=7)
AND !(DAYOFWEEK(clo.date)=1);

最佳答案

INSERT INTO normal_days (user_id, department_id,designation_id,date_cur,clock_in,clock_out)
SELECT clo.user_id, design.department_id , uses.designation_id, clo.date, clo.clock_in, clo.clock_out
FROM clock clo
LEFT JOIN holidays AS hol ON hol.date = clo.date
INNER JOIN users AS uses ON clo.user_id = uses.id
INNER JOIN designations AS design ON design.id = uses.designation_id
WHERE date(clo.created_at) = "2016-06-23"
AND TIMESTAMPDIFF(second,clo.clock_in, clo.clock_out) = 28800
AND !(DAYOFWEEK(clo.date)=7)
AND !(DAYOFWEEK(clo.date)=1)
AND hol.date is NULL ;

关于通过选择不同值插入查询中的 MySQL 语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38047601/

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