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))
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))
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)