roxor roxor - 4 months ago 6x
PHP Question

how to resolve this query below and what is the purpose of using IN operator

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


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';