是否有可能在表中执行sql delete query foreach user_id?
我可以使用SELECT user_id FROM
个用户获取所有user_id
然后我可以删除除
DELETE FROM accounts
WHERE id IN (select * from (SELECT id
FROM accounts
WHERE user_id = 150192618395339835
AND site = 'https://www.paypal.com'
AND time_added < (SELECT Max(time_added)
FROM accounts
WHERE user_id = 150192618395339835
AND site = 'https://www.paypal.com')
ORDER BY time_added ASC) as t)
如何将所有user_id传递给删除查询?
答案 0 :(得分:1)
尝试
WHERE user_id in (SELECT u.user_id FROM users u)
所有查询:
DELETE FROM accounts
WHERE id IN (select * from (SELECT id
FROM accounts
WHERE user_id in (SELECT u.user_id FROM users u)
AND site = 'https://www.paypal.com'
AND time_added < (SELECT Max(time_added)
FROM accounts
WHERE user_id = 150192618395339835
AND site = 'https://www.paypal.com')
ORDER BY time_added ASC) as t)