I'm currently having a problem in SQL.
I have two tables. The first one contains an int value and the int ID of an account and the second one contains some userdata and the value, I want to update.
table:
TABLE (INT AccountID, INT ValueToAdd)
table:
TABLE (INT AccountID, INT ValueToBeUpdated, ...)
I want SQL to look through the 1. table which AccountID
it needs from the 2. table and should then update the ValueToBeUpdated
value where the 1.table.AccountID = 2.table.AccountID
I hope you get what I mean. I didn't find a way to do this in a set-orientated language like SQL yet, as I cant do foreach loops through one of the tables like here:
foreach (row in 2.table)
{
if (row.AccountID IN 1.table.AccountID)
{
UPDATE row SET ValueToBeUpdated = (SELECT ValueToAdd FROM 1.table WHERE AccountID = row.AccountID)
}
}
I hope you can help me out :)