update radcheck SET radcheck.attribute = 'rejected' where radcheck.username IN (select username from radpostauth where radpostauth.username = $mobile AND radpostauth.authdate < now() - 120)");
我希望我的查询更新radcheckauth表中用户名的“属性”列,而radpostauth表中的相同用户名在他的回复列中的值为“ reject”
我需要首先在radpostauth.authdate的基础上更新radpostauth.reply ='reject'
最佳答案
请在mysql查询中使用连接,因为使用连接而不是内部查询会获得更好的性能
update radcheck as rc
JOIN radpostauth asrpa ON (rpa.username = rc.username) AND (rpa.authdate < now() - 120)
SET rc.attribute = 'rejected'
where rpa.reply = 'reject';