Update table based on value in related table
Posted on 2011-09-26
I have 2 tables: aspnet_Users and tblUserProfileData.
Who can I update all users in tblUserProfileData that has one spesific ApplicationId in aspnet_users? The relation between the tables are tblUserProfileData.UserId and aspnet_Users.UserId.
I need to set tblUserProfileData.Payment = '0' where aspnet_Users.ApplicationId = 'aca98bd7-4fee-4bf3-7d21-3b88c9457d57'
This is a select statement that returns all users where I need to set tblUserProfileData.Payment = '0':
SELECT tblUserProfileData.UserId, tblUserProfileData.Payment, aspnet_Users.ApplicationId
FROM tblUserProfileData INNER JOIN
aspnet_Users ON tblUserProfileData.UserId = aspnet_Users.UserId
WHERE (aspnet_Users.ApplicationId = 'aca98bd7-4fee-4bf3-7d21-3b88c9457d57')