Skip to main content
Engineering LibreTexts

16.4: UPDATE statement

  • Page ID
    92224
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    The UPDATE statement changes data in existing rows either by adding new data or modifying existing data.

    This example uses the UPDATE statement to standardize the country field to be Canada for all records in the Publishers table.

    UPDATE Publishers
    SET country = ‘Canada’

    This example increases the royalty amount by 10% for those royalty amounts between 10 and 20.

    UPDATE roysched
    SET royalty = royalty + (royalty * .10)
    WHERE royalty BETWEEN 10 and 20

    Including subqueries in an UPDATE statement

    The employees from the Employees table who were hired by the publisher in 2010 are given a promotion to the highest job level for their job type. This is what the UPDATE statement would look like.

    UPDATE Employees
    SET job_lvl =
    (SELECT max_lvl FROM jobs
    WHERE employee.job_id = jobs.job_id)
    WHERE DATEPART(year, employee.hire_date) = 2010

    16.4: UPDATE statement is shared under a not declared license and was authored, remixed, and/or curated by LibreTexts.

    • Was this article helpful?