Reputation: 11
update radcheck SET radcheck.attribute = 'rejected' where radcheck.username IN (select username from radpostauth where radpostauth.username = $mobile AND radpostauth.authdate < now() - 120)");
i want my query to update column "attribute" of a username in radcheck table when the same username in radpostauth table has value "reject" in his reply column i need to first update radpostauth.reply = 'reject' on the basis of radpostauth.authdate
Upvotes: 0
Views: 139
Reputation: 495
Hi can you please use JOIN with update query
update radcheck
JOIN radpostauth ON radpostauth.authdate < now() - 120
SET radpostauth.reply = 'reject'
update radcheck
JOIN radpostauth ON (radpostauth.username = radcheck.username) AND (radpostauth.authdate < now() - 120)
SET radcheck.attribute = 'rejected'
where radpostauth.reply = 'reject';
Upvotes: 1
Reputation: 36
Please use join in mysql query because better performance use join instead of inner query
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';
Upvotes: 2
Reputation: 133380
based on your description you shuold subseelect the username where adpostauth table has value "reject" in his reply column
update radcheck
SET radcheck.attribute = 'rejected'
where radcheck.username IN (select username
from radpostauth
where radpostauth.reply = 'reject' ");
Upvotes: 0