dswsl2016 2016-06-23 07:21
浏览 51
已采纳

如何在下面解决此查询以及使用IN运算符的目的是什么

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

  • 写回答

3条回答 默认 最新

  • duanlu6114 2016-06-23 08:17
    关注

    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';
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?