gpt4 book ai didi

mysql - 在mysql的左连接中使用限制

转载 作者:行者123 更新时间:2023-11-29 14:33:20 26 4
gpt4 key购买 nike

大家可以帮我解决这个不起作用查询吗?

UPDATE DB_1 
left join blacklist as blk
on DB_1.last_email=blk.email
SET DB_1.sampling = ?
WHERE blk.email IS NULL
and DB_1.sampling IS NULL
LIMIT "+slot;

我当时需要更新 25k 行,但这样做不起作用。如何创建有效的查询?我正在考虑放弃左连接并使用 IN 进行连接。

最佳答案

您想要更新DB_1中不在黑名单中的行吗?

你可以尝试:

UPDATE 
DB_1
SET
DB_1.sampling = ?
WHERE
NOT EXISTS
( SELECT *
FROM blacklist AS blk
WHERE blk.email = DB_1.last_email
)
ORDER BY
<something>
LIMIT
<whatever>

或者:

UPDATE 
DB_1 AS upd
JOIN
( SELECT t.PK
FROM
DB_1 AS t
LEFT JOIN
blacklist AS blk
ON blk.email = t.last_email
WHERE
blk.email IS NULL
ORDER BY
<something>
LIMIT
<whatever>
) AS lim
ON lim.PK = upd.PK
SET
upd.sampling = ?

关于mysql - 在mysql的左连接中使用限制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9601076/

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