In my project I needed to update all my records but the top(1) that is displayed. A very easy and efficient way that I found out to do it is to use syntax like this:
Hello SQL -> Update for me all records but the one that are not in top(1). In SQL this could be translated as the following example.
Example:
UPDATE table1
SET filed1 = 'New value'
WHERE Id NOT IN
(Select TOP(1) Id FROM table1)
You could as well rewrite this using INNER JOIN and achieve the same results.
Hello SQL -> Update for me all records but the one that are not in top(1). In SQL this could be translated as the following example.
Example:
UPDATE table1
SET filed1 = 'New value'
WHERE Id NOT IN
(Select TOP(1) Id FROM table1)
You could as well rewrite this using INNER JOIN and achieve the same results.
No comments:
Post a Comment