Table:
id userid friendid name status
1 1 2 venkat false
2 1 3 sai true
3 1 4 arun false
4 1 5 arjun false
If a user sends userid=1,friendids=2,4,5 status=true
How would I write the query to update the above? All friendids status is true. [2,3,4 at a time]?
To update one column here are some syntax options:
Option 1
Option 2
Option 3
Update
As requested in the comment it might make sense to show how to update multiple columns. So let’s say for the purpose of this exercise that we want not just to update the
statusat ones. We want to updatenameandstatuswhere thefriendidis matching. Here are some syntax options for that:Option 1
Option 2
Option 3
Update 2
In the answer I was using LINQ to SQL and in that case to commit to the database the usage is:
But for Entity Framework to commit the changes it is: