更新表-0行影响

发布于 2025-01-26 05:47:36 字数 513 浏览 5 评论 0原文

我写了一个更新命令,其语法很好,但是不影响任何行,因此它实际上不起作用。 [1] [1]: https://i.sstatic.net/mxinf.png

update T1 c, T2 dk
    set c.date = dk.dates, c.field = 'event_dt'  
where c.id = dk.id and c.age = dk.age and c.height = dk.height and c.country = dk.country
    and c.id is not null and c.date is null and c.age is not null and c.height is not null and c.country is not null;

解决问题? 谢谢!

I wrote an UPDATE command whose syntax is good, but it doesn't affect any of the rows, so it doesn't actually work. [1]
[1]: https://i.sstatic.net/MXinf.png

update T1 c, T2 dk
    set c.date = dk.dates, c.field = 'event_dt'  
where c.id = dk.id and c.age = dk.age and c.height = dk.height and c.country = dk.country
    and c.id is not null and c.date is null and c.age is not null and c.height is not null and c.country is not null;

how can I solve the problem?
thanks!

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

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

发布评论

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

评论(1

薄荷→糖丶微凉 2025-02-02 05:47:36

我建议将其写为更新加入:

UPDATE T1 c
INNER JOIN T2 dk
    ON c.id = dk.id and c.age = dk.age and c.height = dk.height and c.country = dk.country
SET c.date = dk.dates, c.field = 'event_dt'  
WHERE c.id IS NOT NULL AND c.date IS NULL AND c.age IS NOT NULL AND
      c.height IS NOT NULL AND c.country IS NOT NULL;

如果以上也没有更新任何行,则您的数据或逻辑已关闭。

I would suggest writing this as an update join:

UPDATE T1 c
INNER JOIN T2 dk
    ON c.id = dk.id and c.age = dk.age and c.height = dk.height and c.country = dk.country
SET c.date = dk.dates, c.field = 'event_dt'  
WHERE c.id IS NOT NULL AND c.date IS NULL AND c.age IS NOT NULL AND
      c.height IS NOT NULL AND c.country IS NOT NULL;

If the above also does not update any rows, then either your data or your logic is off.

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