gpt4 book ai didi

mysql - 针对特定 ID 和 JOIN LIMIT 1 从多个表更新查询

转载 作者:行者123 更新时间:2023-11-29 21:40:22 25 4
gpt4 key购买 nike

我有两个表,我想每天更新 scrapes 中的 torrents 行。

刮伤:

id, torrent_id, name, status, complete, incomplete, downloaded
1, 1, http://tracker1.com, 1, 542, 23, 542
2, 1, http://tracker2.com, 1, 542, 23, 542
3, 2, http://tracker1.com, 1, 123, 34, 43
4, 2, http://tracker2.com, 1, 123, 34, 43
5, 3, http://tracker1.com, 1, 542, 23, 542
6, 3, http://tracker2.com, 1, 542, 23, 542
7, 4, http://tracker1.com, 1, 123, 34, 43
8, 4, http://tracker2.com, 1, 123, 34, 43
9, 5, http://tracker1.com, 1, 542, 23, 542
10, 5, http://tracker2.com, 1, 542, 23, 542
11, 6, http://tracker1.com, 1, 123, 34, 43
12, 6, http://tracker2.com, 1, 123, 34, 43

种子:

id, name, complete, incomplete, downloaded
1, CentOS, 0, 0, 0
2, Ubuntu, 0, 0, 0
3, Debian, 0, 0, 0
4, Redhat, 0, 0, 0
5, Fedora, 0, 0, 0
6, Gentoo, 0, 0, 0

scrapes 可能有多个 name,但我只想从第一个找到的值获取值(为了获得更好的性能),而且,我只需要更新 torrents id 1, 3, 6 一次查询。

最佳答案

UPDATE (SELECT * FROM scrapes WHERE torrent_id IN(1,3,6) GROUP BY torrent_id) as `myview` JOIN torrents ON myview.torrent_id=torrents.id SET torrent.complete=myview.complete WHERE 1

关于mysql - 针对特定 ID 和 JOIN LIMIT 1 从多个表更新查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34577874/

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