mysql query does not work

0

The query does not work for me. What am I doing wrong?

update users set hasCredit = 1 where users.id = (select users.id from users inner join creditRequest on (users.id = creditRequest.user_id))
    
asked by Santiago Ruiz 02.09.2016 в 17:42
source

1 answer

2

It is not necessary to make this subquery with a JOIN , it would be enough to check the existence in the table CreditRequest or use IN :

update users 
set hasCredit = 1 
where id in (select user_id from credtRequest)

Or with EXISTS :

update users 
set hasCredit = 1 
where exists(select 1 from credtRequest
             WHERE credtRequest.user_id = users.id)
    
answered by 02.09.2016 / 17:50
source