Skip to content

Instantly share code, notes, and snippets.

@jennings
Created July 31, 2012 15:17
Show Gist options
  • Save jennings/3217735 to your computer and use it in GitHub Desktop.
Save jennings/3217735 to your computer and use it in GitHub Desktop.
Composing an update query
--- While composing an update query, it's useful to use
--- a SELECT statement first to make sure you're going to
--- update the correct rows. Formatting the query in
--- this manner lets you alternate between SELECT and UPDATE
--- without commenting and uncommenting parts of the query.
SELECT *
FROM
-- UPDATE TableToUpdate --- Use ALT + Drag to highlight this update
-- SET ColumnToUpdate = Value --- and the where clause when you're ready
-- FROM --- to perform the update
TableToUpdate tu
JOIN SomeJoinTable sj
ON tu.Id = sj.Id
WHERE
tu.Something = 34
AND sj.SomethingElse = 'A'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment