I need to update a column of a set of rows in a Table with given name.
Which query executes faster:
Update .... set... where name in('abc','pqr','mnp','xyz')
or
foreach(string str in namelist){ Update .... set... where name like str }
You use a LIKE when you want to use wildcards... otherwise stay away from them as they are very costly. As for loops, I also try to stay away from them as they are usually costly. So My Personal Opinion? One update statement with the IN clause will give you better performance than a loop and a Like.