SQL查询语法错误

发布于 2024-12-06 06:27:40 字数 410 浏览 0 评论 0原文

我在此查询中遇到语法错误,但我不知道我做错了什么。

UPDATE `jos_planning2_rosters` r
LEFT JOIN jos_planning2_rosters_setup s ON r.id = s.roster_id
LEFT JOIN jos_planning2_workplaces w ON s.workplace_id = w.id
WHERE r.roster_state =1
AND s.card_id IS NULL
AND s.type_id = '2'
AND r.roster_date >= DATE( NOW()) SET s.card_id = '1', s.type_id = '1' 
WHERE s.type_id = '2', s.card_id IS NULL, r.id = '8';

I got a syntax error on this query, but I don't know what I'm doing wrong.

UPDATE `jos_planning2_rosters` r
LEFT JOIN jos_planning2_rosters_setup s ON r.id = s.roster_id
LEFT JOIN jos_planning2_workplaces w ON s.workplace_id = w.id
WHERE r.roster_state =1
AND s.card_id IS NULL
AND s.type_id = '2'
AND r.roster_date >= DATE( NOW()) SET s.card_id = '1', s.type_id = '1' 
WHERE s.type_id = '2', s.card_id IS NULL, r.id = '8';

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

虚拟世界 2024-12-13 06:27:40

您的查询中有两个 WHERE 子句。

You have two WHERE clauses in your query.

淡忘如思 2024-12-13 06:27:40

您是否尝试这样做,查询一团糟:

UPDATE s
SET    s.card_id = '1', 
       s.type_id = '1'
From   jos_planning2_rosters_setup s
       INNER JOIN jos_planning2_rosters r ON r.id = s.roster_id
WHERE  r.roster_state = 1
       AND s.card_id IS NULL
       AND s.type_id = '2'
       AND r.roster_date >= GetDate()
       AND r.id = '8';

Are you trying to do this, the query is a mess:

UPDATE s
SET    s.card_id = '1', 
       s.type_id = '1'
From   jos_planning2_rosters_setup s
       INNER JOIN jos_planning2_rosters r ON r.id = s.roster_id
WHERE  r.roster_state = 1
       AND s.card_id IS NULL
       AND s.type_id = '2'
       AND r.roster_date >= GetDate()
       AND r.id = '8';
雨后咖啡店 2024-12-13 06:27:40

尝试一下,不要在 jos_planning2_rosters 周围添加反引号。

Try it without those backticks around jos_planning2_rosters.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文