{"id":13761,"date":"2023-12-29T01:02:30","date_gmt":"2023-12-29T08:02:30","guid":{"rendered":"https:\/\/www.mysqltutorial.org\/?page_id=13761"},"modified":"2023-12-29T01:02:31","modified_gmt":"2023-12-29T08:02:31","slug":"mysql-update","status":"publish","type":"page","link":"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-update\/","title":{"rendered":"MySQL UPDATE"},"content":{"rendered":"\n<p><strong>Summary<\/strong>: updating data is one of the most important tasks when you work with the database. In this tutorial, you will learn how to use the MySQL <code>UPDATE<\/code> statement to update data in a table.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Introduction to MySQL UPDATE statement<\/h2>\n\n\n\n<p>The <code>UPDATE<\/code> statement updates data in a table. It allows you to change the values in one or more columns of a single row or multiple rows.<\/p>\n\n\n\n<p>The following illustrates the basic syntax of the <code>UPDATE<\/code> statement:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">UPDATE<\/span> &#91;<span class=\"hljs-keyword\">LOW_PRIORITY<\/span>] &#91;<span class=\"hljs-keyword\">IGNORE<\/span>] table_name \n<span class=\"hljs-keyword\">SET<\/span> \n    column_name1 = expr1,\n    column_name2 = expr2,\n    ...\n&#91;<span class=\"hljs-keyword\">WHERE<\/span>\n    condition];<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>In this syntax:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>First, specify the name of the table that you want to update data after the <code>UPDATE<\/code> keyword.<\/li>\n\n\n\n<li>Second, specify which column you want to update and the new value in the <code>SET<\/code> clause. To update values in multiple columns, you use a list of comma-separated assignments by supplying a value in each column&#8217;s assignment in the form of a literal value, an expression, or a <a title=\"MySQL Subquery\" href=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-subquery\/\">subquery<\/a>.<\/li>\n\n\n\n<li>Third, specify which rows to be updated using a condition in the <code><a href=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-where\/\">WHERE<\/a><\/code>&nbsp;clause. The <code>WHERE<\/code> clause is optional. If you omit it, the <code>UPDATE<\/code> statement will modify all rows&nbsp;in the table.<\/li>\n<\/ul>\n\n\n\n<p>Notice that the&nbsp;<code>WHERE<\/code> clause is so important that you should not forget. Sometimes, you may want to update just one row; However, you may forget the <code>WHERE<\/code> clause and accidentally update all rows of the table.<\/p>\n\n\n\n<p>MySQL supports two modifiers in the <code>UPDATE<\/code> statement.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>The <code>LOW_PRIORITY<\/code> modifier instructs the <code>UPDATE<\/code> statement to delay the update until there is no connection reading data from the table. The <code>LOW_PRIORITY<\/code> takes effect for the <a href=\"https:\/\/www.mysqltutorial.org\/mysql-administration\/mysql-storage-engines\/\">storage engines<\/a> that use table-level <a href=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-table-locking\/\">locking<\/a> only such as <code>MyISAM<\/code>, <code>MERGE<\/code>, and <code>MEMORY<\/code>.<\/li>\n\n\n\n<li>The <code>IGNORE<\/code> modifier enables the <code>UPDATE<\/code> statement to continue updating rows even if errors occurred. The rows that cause errors such as duplicate-key conflicts are not updated.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">MySQL UPDATE examples<\/h2>\n\n\n\n<p>Let&#8217;s practice the <code>UPDATE<\/code> statement.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1) Using MySQL UPDATE to modify values in a single column example<\/h3>\n\n\n\n<p>See the following <code>employees<\/code> table from the <a href=\"https:\/\/www.mysqltutorial.org\/getting-started-with-mysql\/mysql-sample-database\/\">sample database<\/a>.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"206\" height=\"219\" src=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2013\/02\/employees_table.png\" alt=\"Employees Table\" class=\"wp-image-1510\"\/><\/figure>\n\n\n\n<p>In this example, we will update the email of <code>Mary Patterson<\/code> to the new email <code>mary.patterso@classicmodelcars.com<\/code><em>.<\/em><\/p>\n\n\n\n<p>First, find Mary&#8217;s email from the <code>employees<\/code> table using the following <code><a href=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-select-from\/\">SELECT<\/a><\/code> statement:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">SELECT<\/span> \n    firstname, \n    lastname, \n    email\n<span class=\"hljs-keyword\">FROM<\/span>\n    employees\n<span class=\"hljs-keyword\">WHERE<\/span>\n    employeeNumber = <span class=\"hljs-number\">1056<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"330\" height=\"45\" src=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2013\/01\/MySQL-Update-example.jpg\" alt=\"MySQL Update example\" class=\"wp-image-4805\" title=\"MySQL Update example\" srcset=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2013\/01\/MySQL-Update-example.jpg 330w, https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2013\/01\/MySQL-Update-example-300x41.jpg 300w\" sizes=\"auto, (max-width: 330px) 100vw, 330px\" \/><\/figure>\n\n\n\n<p>Second, update the email address of <code>Mary<\/code> to the new email <code>mary.patterson@classicmodelcars.com<\/code> :<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">UPDATE<\/span> employees \n<span class=\"hljs-keyword\">SET<\/span> \n    email = <span class=\"hljs-string\">'mary.patterson@classicmodelcars.com'<\/span>\n<span class=\"hljs-keyword\">WHERE<\/span>\n    employeeNumber = <span class=\"hljs-number\">1056<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>MySQL issued the number of rows affected:<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">1 row(s) affected<\/code><\/span><\/pre>\n\n\n<p>In this <code>UPDATE<\/code> statement:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The <code><a href=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-where\/\">WHERE<\/a><\/code> clause specifies the row with employee number <code>1056<\/code> will be updated.<\/li>\n\n\n\n<li>The <code>SET<\/code> clause sets the value of the <code>email<\/code> column to the new email.<\/li>\n<\/ul>\n\n\n\n<p>Third,&nbsp; execute the <code>SELECT<\/code> statement again to verify the change:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">SELECT<\/span> \n    firstname, \n    lastname, \n    email\n<span class=\"hljs-keyword\">FROM<\/span>\n    employees\n<span class=\"hljs-keyword\">WHERE<\/span>\n    employeeNumber = <span class=\"hljs-number\">1056<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"355\" height=\"43\" src=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2013\/01\/MySQL-UPDATE-table-example.jpg\" alt=\"MySQL UPDATE table example\" class=\"wp-image-4806\" title=\"MySQL UPDATE table example\" srcset=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2013\/01\/MySQL-UPDATE-table-example.jpg 355w, https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2013\/01\/MySQL-UPDATE-table-example-300x36.jpg 300w\" sizes=\"auto, (max-width: 355px) 100vw, 355px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">2) Using MySQL UPDATE to modify values in multiple columns<\/h3>\n\n\n\n<p>To update values in the multiple columns, you need to specify the assignments in the <code>SET<\/code> clause. For example, the following statement updates both last name and email columns of employee number 1056:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">UPDATE<\/span> employees \n<span class=\"hljs-keyword\">SET<\/span> \n    lastname = <span class=\"hljs-string\">'Hill'<\/span>,\n    email = <span class=\"hljs-string\">'mary.hill@classicmodelcars.com'<\/span>\n<span class=\"hljs-keyword\">WHERE<\/span>\n    employeeNumber = <span class=\"hljs-number\">1056<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Let&#8217;s verify the changes:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">SELECT<\/span> \n    firstname, \n    lastname, \n    email\n<span class=\"hljs-keyword\">FROM<\/span>\n    employees\n<span class=\"hljs-keyword\">WHERE<\/span>\n    employeeNumber = <span class=\"hljs-number\">1056<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"316\" height=\"44\" src=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2013\/01\/MySQL-UPDATE-multiple-columns.jpg\" alt=\"MySQL UPDATE multiple columns\" class=\"wp-image-4807\" srcset=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2013\/01\/MySQL-UPDATE-multiple-columns.jpg 316w, https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2013\/01\/MySQL-UPDATE-multiple-columns-300x42.jpg 300w\" sizes=\"auto, (max-width: 316px) 100vw, 316px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">3) Using MySQL UPDATE to replace string example<\/h3>\n\n\n\n<p>The following example updates the domain parts of emails of all <code>Sales Reps<\/code> with office code <code>6<\/code>:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-7\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">UPDATE<\/span> employees\n<span class=\"hljs-keyword\">SET<\/span> email = <span class=\"hljs-keyword\">REPLACE<\/span>(email,<span class=\"hljs-string\">'@classicmodelcars.com'<\/span>,<span class=\"hljs-string\">'@mysqltutorial.org'<\/span>)\n<span class=\"hljs-keyword\">WHERE<\/span>\n   jobTitle = <span class=\"hljs-string\">'Sales Rep'<\/span> <span class=\"hljs-keyword\">AND<\/span>\n   officeCode = <span class=\"hljs-number\">6<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>In this example, the <code><a href=\"https:\/\/www.mysqltutorial.org\/mysql-string-functions\/mysql-replace-function\/\">REPLACE<\/a>()<\/code> function replaces <code>@classicmodelcars.com<\/code>&nbsp;in the email column with <code>@mysqltutorial.org<\/code>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">4) Using MySQL UPDATE to update rows returned by a SELECT statement example<\/h3>\n\n\n\n<p>You can supply&nbsp;the values for the <code>SET<\/code> clause from a <code>SELECT<\/code> statement that queries&nbsp;data from other tables.<\/p>\n\n\n\n<p>For example,&nbsp;in the <code>customers<\/code> table, some customers do not have any sale representative. The value of the column <code>saleRepEmployeeNumber<\/code> is <code>NULL<\/code> as follows:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-8\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">SELECT<\/span> \n    customername, \n    salesRepEmployeeNumber\n<span class=\"hljs-keyword\">FROM<\/span>\n    customers\n<span class=\"hljs-keyword\">WHERE<\/span>\n    salesRepEmployeeNumber <span class=\"hljs-keyword\">IS<\/span> <span class=\"hljs-literal\">NULL<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-8\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"315\" height=\"195\" src=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2013\/01\/MySQL-UPDATE-From-SELECT-example.jpg\" alt=\"MySQL UPDATE From SELECT example\" class=\"wp-image-4808\" title=\"MySQL UPDATE From SELECT example\" srcset=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2013\/01\/MySQL-UPDATE-From-SELECT-example.jpg 315w, https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2013\/01\/MySQL-UPDATE-From-SELECT-example-300x186.jpg 300w\" sizes=\"auto, (max-width: 315px) 100vw, 315px\" \/><\/figure>\n\n\n\n<p>We can take a&nbsp;sale representative and update for those customers.<\/p>\n\n\n\n<p>To do this, we can select a random employee whose job title is <code>Sales Rep<\/code> from the &nbsp;<code>employees<\/code> table and update it for the &nbsp;<code>employees<\/code> table.<\/p>\n\n\n\n<p>This query <a href=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-select-random\/\">selects a random<\/a> employee from the table <code>employees<\/code> whose job title is the <code>Sales Rep<\/code>.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-9\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">SELECT<\/span> \n    employeeNumber\n<span class=\"hljs-keyword\">FROM<\/span>\n    employees\n<span class=\"hljs-keyword\">WHERE<\/span>\n    jobtitle = <span class=\"hljs-string\">'Sales Rep'<\/span>\n<span class=\"hljs-keyword\">ORDER<\/span> <span class=\"hljs-keyword\">BY<\/span> <span class=\"hljs-keyword\">RAND<\/span>()\n<span class=\"hljs-keyword\">LIMIT<\/span> <span class=\"hljs-number\">1<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-9\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>To update the sales representative employee number&nbsp; column in the <code>customers<\/code> table, we place the query above in the <code>SET<\/code> clause of the <code>UPDATE<\/code> statement as follows:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-10\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">UPDATE<\/span> customers \n<span class=\"hljs-keyword\">SET<\/span> \n    salesRepEmployeeNumber = (<span class=\"hljs-keyword\">SELECT<\/span> \n            employeeNumber\n        <span class=\"hljs-keyword\">FROM<\/span>\n            employees\n        <span class=\"hljs-keyword\">WHERE<\/span>\n            jobtitle = <span class=\"hljs-string\">'Sales Rep'<\/span>\n        <span class=\"hljs-keyword\">ORDER<\/span> <span class=\"hljs-keyword\">BY<\/span> <span class=\"hljs-keyword\">RAND<\/span>()\n        <span class=\"hljs-keyword\">LIMIT<\/span> <span class=\"hljs-number\">1<\/span>)\n<span class=\"hljs-keyword\">WHERE<\/span>\n    salesRepEmployeeNumber <span class=\"hljs-keyword\">IS<\/span> <span class=\"hljs-literal\">NULL<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-10\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>If you query data from the &nbsp;<code>employees<\/code> table, you will see that every customer has a sales representative. In other words, the following query returns no row.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-11\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">SELECT<\/span> \n     salesRepEmployeeNumber\n<span class=\"hljs-keyword\">FROM<\/span>\n    customers\n<span class=\"hljs-keyword\">WHERE<\/span>\n    salesRepEmployeeNumber <span class=\"hljs-keyword\">IS<\/span> <span class=\"hljs-literal\">NULL<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-11\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>In this tutorial, you have learned how to use MySQL <code>UPDATE<\/code> statement to update data in a database table.<\/p>\n<div class=\"helpful-block-content\" data-title=\"\">\n\t<header>\n\t\t<div class=\"wth-question\">Was this tutorial helpful? <\/div>\n\t\t<div class=\"wth-thumbs\">\n\t\t\t<button\n\t\t\t\tdata-post=\"13761\"\n\t\t\t\tdata-post-url=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-update\/\"\n\t\t\t\tdata-post-title=\"MySQL UPDATE\"\n\t\t\t\tdata-response=\"1\"\n\t\t\t\tclass=\"wth-btn-rounded wth-yes-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t\tclass=\"feather feather-thumbs-up block w-full h-full\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> Yes <\/span>\n\t\t\t<\/button>\n\n\t\t\t<button\n\t\t\t\tdata-response=\"0\"\n\t\t\t\tdata-post=\"13761\"\n\t\t\t\tdata-post-url=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-update\/\"\n\t\t\t\tdata-post-title=\"MySQL UPDATE\"\n\t\t\t\tclass=\"wth-btn-rounded wth-no-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> No <\/span>\n\t\t\t<\/button>\n\t\t<\/div>\n\t<\/header>\n\n\t<div class=\"wth-form hidden\">\n\t\t<div class=\"wth-form-wrapper\">\n\t\t\t<div class=\"wth-title\"><\/div>\n\t\t\t\n\t\t\t<textarea class=\"wth-message\"><\/textarea>\n\n\t\t\t<button class=\"btn btn-primary wth-btn-submit\">Send<\/button>\n\t\t\t<button class=\"btn wth-btn-cancel\">Cancel<\/button>\n\t\t\n\t\t<\/div>\n\t<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Summary: updating data is one of the most important tasks when you work with the database. In this tutorial, you will learn how to use the MySQL UPDATE statement to update data in a table. Introduction to MySQL UPDATE statement The UPDATE statement updates data in a table. It allows you to change the values [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"parent":174,"menu_order":59,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-13761","page","type-page","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>MySQL UPDATE<\/title>\n<meta name=\"description\" content=\"In this tutorial, you will learn how to use MySQL UPDATE statement to update data in a table.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-update\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"MySQL UPDATE\" \/>\n<meta property=\"og:description\" content=\"In this tutorial, you will learn how to use MySQL UPDATE statement to update data in a table.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-update\/\" \/>\n<meta property=\"og:site_name\" content=\"MySQL Tutorial\" \/>\n<meta property=\"article:modified_time\" content=\"2023-12-29T08:02:31+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2013\/02\/employees_table.png\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-basics\\\/mysql-update\\\/\",\"url\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-basics\\\/mysql-update\\\/\",\"name\":\"MySQL UPDATE\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-basics\\\/mysql-update\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-basics\\\/mysql-update\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.mysqltutorial.org\\\/wp-content\\\/uploads\\\/2013\\\/02\\\/employees_table.png\",\"datePublished\":\"2023-12-29T08:02:30+00:00\",\"dateModified\":\"2023-12-29T08:02:31+00:00\",\"description\":\"In this tutorial, you will learn how to use MySQL UPDATE statement to update data in a table.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-basics\\\/mysql-update\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-basics\\\/mysql-update\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-basics\\\/mysql-update\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.mysqltutorial.org\\\/wp-content\\\/uploads\\\/2013\\\/02\\\/employees_table.png\",\"contentUrl\":\"https:\\\/\\\/www.mysqltutorial.org\\\/wp-content\\\/uploads\\\/2013\\\/02\\\/employees_table.png\",\"width\":206,\"height\":219,\"caption\":\"Employees Table\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-basics\\\/mysql-update\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.mysqltutorial.org\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"MySQL Basics\",\"item\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-basics\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"MySQL UPDATE\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/#website\",\"url\":\"https:\\\/\\\/www.mysqltutorial.org\\\/\",\"name\":\"MySQL Tutorial\",\"description\":\"A comprehensive MySQL Tutorial\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.mysqltutorial.org\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"MySQL UPDATE","description":"In this tutorial, you will learn how to use MySQL UPDATE statement to update data in a table.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-update\/","og_locale":"en_US","og_type":"article","og_title":"MySQL UPDATE","og_description":"In this tutorial, you will learn how to use MySQL UPDATE statement to update data in a table.","og_url":"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-update\/","og_site_name":"MySQL Tutorial","article_modified_time":"2023-12-29T08:02:31+00:00","og_image":[{"url":"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2013\/02\/employees_table.png","type":"","width":"","height":""}],"twitter_misc":{"Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-update\/","url":"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-update\/","name":"MySQL UPDATE","isPartOf":{"@id":"https:\/\/www.mysqltutorial.org\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-update\/#primaryimage"},"image":{"@id":"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-update\/#primaryimage"},"thumbnailUrl":"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2013\/02\/employees_table.png","datePublished":"2023-12-29T08:02:30+00:00","dateModified":"2023-12-29T08:02:31+00:00","description":"In this tutorial, you will learn how to use MySQL UPDATE statement to update data in a table.","breadcrumb":{"@id":"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-update\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-update\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-update\/#primaryimage","url":"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2013\/02\/employees_table.png","contentUrl":"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2013\/02\/employees_table.png","width":206,"height":219,"caption":"Employees Table"},{"@type":"BreadcrumbList","@id":"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-update\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.mysqltutorial.org\/"},{"@type":"ListItem","position":2,"name":"MySQL Basics","item":"https:\/\/www.mysqltutorial.org\/mysql-basics\/"},{"@type":"ListItem","position":3,"name":"MySQL UPDATE"}]},{"@type":"WebSite","@id":"https:\/\/www.mysqltutorial.org\/#website","url":"https:\/\/www.mysqltutorial.org\/","name":"MySQL Tutorial","description":"A comprehensive MySQL Tutorial","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.mysqltutorial.org\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/pages\/13761","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/comments?post=13761"}],"version-history":[{"count":2,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/pages\/13761\/revisions"}],"predecessor-version":[{"id":13763,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/pages\/13761\/revisions\/13763"}],"up":[{"embeddable":true,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/pages\/174"}],"wp:attachment":[{"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/media?parent=13761"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}