{"id":8501,"date":"2020-11-26T07:22:00","date_gmt":"2020-11-26T07:22:00","guid":{"rendered":"https:\/\/ubiq.co\/tech-blog\/?p=8501"},"modified":"2026-03-16T04:49:37","modified_gmt":"2026-03-16T04:49:37","slug":"how-to-update-a-column-based-on-another-column-in-sql","status":"publish","type":"post","link":"https:\/\/ubiq.co\/tech-blog\/how-to-update-a-column-based-on-another-column-in-sql\/","title":{"rendered":"How To Update a Column Based on Another Column in SQL"},"content":{"rendered":"\n<p>Every database allows you to update one or more columns in your tables. You can update them based on their own values, values of another column(s) in the same table. Sometimes you may need to update a column in table based on value of another column in table. In this article, we will learn how to update a column based on another column in SQL Server, MySQL, PostgreSQL.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-update-a-column-based-on-another-column-in-sql\/#How_To_Update_a_Column_Based_on_Another_Column_in_SQL\" >How To Update a Column Based on Another Column in SQL<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-update-a-column-based-on-another-column-in-sql\/#1_Using_WHERE_clause\" >1. Using WHERE clause<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-update-a-column-based-on-another-column-in-sql\/#2_Using_CASE_statement\" >2. Using CASE statement<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-update-a-column-based-on-another-column-in-sql\/#3_Update_Column_Based_on_Another_Table\" >3. Update Column Based on Another Table<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-update-a-column-based-on-another-column-in-sql\/#Conclusion\" >Conclusion<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"How_To_Update_a_Column_Based_on_Another_Column_in_SQL\"><\/span>How To Update a Column Based on Another Column in SQL<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>There are a couple of different ways to <a href=\"https:\/\/ubiq.co\/tech-blog\/how-to-update-multiple-columns-in-mysql\/\">update database columns<\/a>. Here are the steps to update a column based on another column in SQL.<\/p>\n\n\n\n<p>Let us say you have the following table <em>employees(id, first_name, last_name)<\/em><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mysql&gt; create table employees(id int, \n      first_name varchar(255),\n      last_name varchar(255));\n\nmysql&gt; insert into employees(id, first_name, last_name)\n       values(1,'John','Doe'),\n       (2,'Jane','Doe');\n\nmysql&gt; select * from employees;\n+------+------------+-----------+\n| id   | first_name | last_name |\n+------+------------+-----------+\n|    1 | John       | Doe       |\n|    2 | Jane       | Doe       |\n+------+------------+-----------+<\/pre>\n\n\n\n<p>Since we need to update one or more columns in one table based on another column&#8217;s values, it is called as conditional update, instead of updating all values of a column. There are two ways to update column based on value of another column &#8211; using WHERE clause and using CASE statement.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"1_Using_WHERE_clause\"><\/span>1. Using WHERE clause<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>In this approach, we use a WHERE clause in the UPDATE&#8230;SET statement. The database will look for rows matching the WHERE condition and then update column values of those rows only. Here is its syntax.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">UPDATE table_name<br>SET column_name = new_value<br>WHERE column_name = old_value;<\/pre>\n\n\n\n<p>Here is the SQL query to change the first_name column value from John to Tim.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mysql&gt; update employees<br>       set first_name='Tim'<br>       where first_name='Jim';<br><br>mysql&gt; select * from employees;<br>+------+------------+-----------+<br>| id   | first_name | last_name |<br>+------+------------+-----------+<br>|    1 | Tim        | Doe       |<br>|    2 | Jane       | Doe       |<br>+------+------------+-----------+<\/pre>\n\n\n\n<p>You can also use another column name in WHERE clause to update a column based on another column&#8217;s value.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">UPDATE table_name<br>SET column_name1 = new_value<br>WHERE column_name2 = other_value;<\/pre>\n\n\n\n<p>Here&#8217;s the SQL query to update <em>first_name<\/em> column based on value of id columns using WHERE clause.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mysql&gt; update employees\n       set first_name='Tim'\n       where id=1;\nmysql&gt; select * from employees;\n+------+------------+-----------+\n| id   | first_name | last_name |\n+------+------------+-----------+\n|    1 | Tim        | Doe       |\n|    2 | Jane       | Doe       |\n+------+------------+-----------+<\/pre>\n\n\n\n<p>In the above statement, the UPDATE statement will first select rows that match the WHERE clause and update value of our column <em>first_name<\/em><\/p>\n\n\n\n<p>You can also use logical operators like AND\/OR in your WHERE clause as shown below.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mysql&gt; update employees\n       set first_name='Tim'\n       where <strong>id=1 or id=3<\/strong>;<\/pre>\n\n\n\n<p>You can also use an IN operator in WHERE clause as shown below.<\/p>\n\n\n\n<pre id=\"block-ef09dd2e-1c82-452a-8e85-6499c1af5c2b\" class=\"wp-block-preformatted\">mysql&gt; update employees\n       set first_name='Tim'\n       where id <strong>in (1,3)<\/strong>;<\/pre>\n\n\n\n<p>You can also use another SELECT query in your WHERE clause as shown below. <\/p>\n\n\n\n<pre id=\"block-78d8313e-3ed2-4185-bacc-d726959a7082\" class=\"wp-block-preformatted\">mysql&gt; update employees\n       set first_name='Tim'\n       where id in ( <strong>select id from emp2<\/strong> );<\/pre>\n\n\n\n<p>In this case, all those rows whose id value matches one of the values returned by SELECT query, will be updated.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"2_Using_CASE_statement\"><\/span>2. Using CASE statement<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Here&#8217;s the SQL query to update <em>first_name<\/em> column based on value of <em>id<\/em> column using CASE statement.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mysql&gt; update employees\n     set first_name = (CASE\n                           WHEN id = 1\n                             THEN 'Tim'\n                           WHEN id = 2\n                             THEN 'Dave'\n                           END);\n\nmysql&gt; select * from employees;\n+------+------------+-----------+\n| id   | first_name | last_name |\n+------+------------+-----------+\n|    1 | Tim        | Doe       |\n|    2 | Dave       | Doe       |\n+------+------------+-----------+<\/pre>\n\n\n\n<p>We use a CASE statement to specify new value of <em>first_name<\/em> column for each value of <em>id<\/em> column. This is a much better approach than using WHERE clause because with WHERE clause we can only change a column value to one new value. With CASE statement, we can update our column value to various values, depending on the individual values of id column.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"3_Update_Column_Based_on_Another_Table\"><\/span>3. Update Column Based on Another Table<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>You can also update column in one table from another column in a different table. Let us say you also have another table <em>emp2(id, first_name, last_name)<\/em> and you want to update <em>first_name<\/em> in <em>employees<\/em> table to <em>first_name<\/em> in <em>emp2<\/em> table. Both tables also have same <em>id<\/em> column values. <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mysql&gt; create table emp2(id int,<br>       first_name varchar(255),<br>       last_name varchar(255));<br><br>mysql&gt; insert into emp2(id, first_name, last_name)<br>            values(1,'Don','Stone'),<br>            (2,'Jim','Stew');<br><br>mysql&gt; select * from emp2;<br>+------+------------+-----------+<br>| id   | first_name | last_name |<br>+------+------------+-----------+<br>|    1 | Don        | Stone     |<br>|    2 | Jim        | Stew      |<br>+------+------------+-----------+<\/pre>\n\n\n\n<p>In such a case, you can use the following UPDATE statement syntax to update column from one table, based on value of another table.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>UPDATE first_table, second_table <\/code>\n<code>SET first_table.column1 = second_table.column2 <\/code>\n<code>WHERE first_table.id = second_table.table_id;<\/code><\/pre>\n\n\n\n<p>Here&#8217;s an SQL query to update <em>first_name<\/em> column in <em>employees<\/em> table to <em>first_name<\/em> column in <em>emp2<\/em> table.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mysql&gt; UPDATE employees, emp2\nSET employees.first_name = emp2.first_name\nWHERE employees.id = emp2.id;\n\nmysql&gt; select * from employees;\n+------+------------+-----------+\n| id   | first_name | last_name |\n+------+------------+-----------+\n|    1 | Don        | Doe       |\n|    2 | Jim        | Doe       |\n+------+------------+-----------+<\/pre>\n\n\n\n<p>Alternatively, you can also use a subquery to supply the list of values in WHERE clause as shown below.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">UPDATE table1<br>SET column1 = value<br>WHERE column2 IN (<br>SELECT column3<br>FROM table2<br>WHERE column4 = some_value<br>);<\/pre>\n\n\n\n<p>Here is an example to update . Let us say you have the following two tables employees and emp2.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mysql&gt; select * from employees;<br>+------+------------+-----------+<br>| id   | first_name | last_name |<br>+------+------------+-----------+<br>|    1 | John       | Doe       |<br>|    2 | Jane       | Doe       |<br>+------+------------+-----------+<br><br>mysql&gt; select * from emp2;<br>+------+------------+-----------+<br>| id   | first_name | last_name |<br>+------+------------+-----------+<br>|    1 | Tim        | Doe       |<br>|    2 | Jane       | Doe       |<br>+------+------------+-----------+<br><br>mysql&gt; UPDATE employees<br>       SET last_name = 'David'<br>       WHERE last_name IN (<br>           SELECT last_name<br>           FROM emp2<br>           WHERE id = 1<br>       );<br><br>mysql&gt; select * from employees;<br>+------+------------+-----------+<br>| id   | first_name | last_name |<br>+------+------------+-----------+<br>|    1 | John       | David     |<br>|    2 | Jane       | David     |<br>+------+------------+-----------+<\/pre>\n\n\n\n<p>You can also set the new value to the result of a subquery as shown below. Of course, this is complicated and shown only for the sake of completeness.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">UPDATE table1<br>SET column1 = (<br>SELECT column2<br>FROM table2<br>WHERE table2.id = table1.id<br>)<\/pre>\n\n\n\n<p>Here is an example to update first_name column in employees table based on the first_name column in emp2 table, for matching id column values.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mysql&gt; UPDATE employees<br>SET employees.first_name = (<br>SELECT emp2.first_name<br>FROM emp2<br>WHERE employees.id = emp2.id<br>);<br><br>mysql&gt; select * from employees<br>+------+------------+-----------+<br>| id   | first_name | last_name |<br>+------+------------+-----------+<br>|    1 | Tim        | Doe       |<br>|    2 | Jane       | Doe       |<br>+------+------------+-----------+<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>In this article, we have learnt several simple ways to update column value based on same or another column&#8217;s value in the same or another table. You can use these SQL queries in all major databases such as MySQL, PostgreSQL, SQL Server, Oracle.<\/p>\n\n\n\n<p><a href=\"https:\/\/ubiq.co\/\">Ubiq<\/a>&nbsp;makes it easy to visualize data, and monitor them in real-time dashboards.&nbsp;<a href=\"https:\/\/ubiq.co\/accounts\/register\">Try Ubiq<\/a>&nbsp;for free.<\/p>\n\n\n\n<p>Also read<br><a href=\"https:\/\/ubiq.co\/tech-blog\/how-to-escape-single-quote-special-characters-in-mysql\/\">How to Escape Single quote, special characters in MySQL<\/a><br><a href=\"https:\/\/ubiq.co\/tech-blog\/how-to-store-json-data-in-mysql\/\">How to Store JSON Data in MySQL<\/a><br><a href=\"https:\/\/ubiq.co\/tech-blog\/how-to-compare-null-values-in-mysql\/\">How to Compare Null Values in MySQL<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here is how to update a column based on another column in SQL Server, MySQL, PostgreSQL.<\/p>\n","protected":false},"author":1,"featured_media":8502,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[324],"tags":[474],"class_list":["post-8501","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-mysql","tag-update-column"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How To Update a Column Based on Another Column in SQL - Ubiq BI<\/title>\n<meta name=\"description\" content=\"Here is how to update a column based on another column in SQL Server, MySQL, PostgreSQL.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-update-a-column-based-on-another-column-in-sql\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How To Update a Column Based on Another Column in SQL - Ubiq BI\" \/>\n<meta property=\"og:description\" content=\"Here is how to update a column based on another column in SQL Server, MySQL, PostgreSQL.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/ubiq.co\/tech-blog\/how-to-update-a-column-based-on-another-column-in-sql\/\" \/>\n<meta property=\"og:site_name\" content=\"Ubiq BI\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/ubiqbi\" \/>\n<meta property=\"article:published_time\" content=\"2020-11-26T07:22:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-03-16T04:49:37+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/06\/update-column-based-another-table.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"720\" \/>\n\t<meta property=\"og:image:height\" content=\"375\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"Sreeram Sreenivasan\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@UbiqBI\" \/>\n<meta name=\"twitter:site\" content=\"@UbiqBI\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Sreeram Sreenivasan\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-update-a-column-based-on-another-column-in-sql\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-update-a-column-based-on-another-column-in-sql\\\/\"},\"author\":{\"name\":\"Sreeram Sreenivasan\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#\\\/schema\\\/person\\\/db98d49a766a3a111d8510935ab90abc\"},\"headline\":\"How To Update a Column Based on Another Column in SQL\",\"datePublished\":\"2020-11-26T07:22:00+00:00\",\"dateModified\":\"2026-03-16T04:49:37+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-update-a-column-based-on-another-column-in-sql\\\/\"},\"wordCount\":730,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-update-a-column-based-on-another-column-in-sql\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2025\\\/06\\\/update-column-based-another-table.webp?fit=720%2C375&ssl=1\",\"keywords\":[\"update column\"],\"articleSection\":[\"MySQL\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-update-a-column-based-on-another-column-in-sql\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-update-a-column-based-on-another-column-in-sql\\\/\",\"url\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-update-a-column-based-on-another-column-in-sql\\\/\",\"name\":\"How To Update a Column Based on Another Column in SQL - Ubiq BI\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-update-a-column-based-on-another-column-in-sql\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-update-a-column-based-on-another-column-in-sql\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2025\\\/06\\\/update-column-based-another-table.webp?fit=720%2C375&ssl=1\",\"datePublished\":\"2020-11-26T07:22:00+00:00\",\"dateModified\":\"2026-03-16T04:49:37+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#\\\/schema\\\/person\\\/db98d49a766a3a111d8510935ab90abc\"},\"description\":\"Here is how to update a column based on another column in SQL Server, MySQL, PostgreSQL.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-update-a-column-based-on-another-column-in-sql\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-update-a-column-based-on-another-column-in-sql\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-update-a-column-based-on-another-column-in-sql\\\/#primaryimage\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2025\\\/06\\\/update-column-based-another-table.webp?fit=720%2C375&ssl=1\",\"contentUrl\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2025\\\/06\\\/update-column-based-another-table.webp?fit=720%2C375&ssl=1\",\"width\":720,\"height\":375,\"caption\":\"update column based in another table\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-update-a-column-based-on-another-column-in-sql\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How To Update a Column Based on Another Column in SQL\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#website\",\"url\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/\",\"name\":\"Ubiq BI\",\"description\":\"Build dashboards &amp; reports in minutes\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#\\\/schema\\\/person\\\/db98d49a766a3a111d8510935ab90abc\",\"name\":\"Sreeram Sreenivasan\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g\",\"caption\":\"Sreeram Sreenivasan\"},\"description\":\"Sreeram Sreenivasan is the Founder of Ubiq. He has helped many Fortune 500 companies in the areas of BI &amp; software development.\",\"sameAs\":[\"https:\\\/\\\/www.linkedin.com\\\/in\\\/sreeram-sreenivasan\\\/\"],\"url\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/author\\\/wordpress\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How To Update a Column Based on Another Column in SQL - Ubiq BI","description":"Here is how to update a column based on another column in SQL Server, MySQL, PostgreSQL.","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:\/\/ubiq.co\/tech-blog\/how-to-update-a-column-based-on-another-column-in-sql\/","og_locale":"en_US","og_type":"article","og_title":"How To Update a Column Based on Another Column in SQL - Ubiq BI","og_description":"Here is how to update a column based on another column in SQL Server, MySQL, PostgreSQL.","og_url":"https:\/\/ubiq.co\/tech-blog\/how-to-update-a-column-based-on-another-column-in-sql\/","og_site_name":"Ubiq BI","article_publisher":"https:\/\/www.facebook.com\/ubiqbi","article_published_time":"2020-11-26T07:22:00+00:00","article_modified_time":"2026-03-16T04:49:37+00:00","og_image":[{"width":720,"height":375,"url":"https:\/\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/06\/update-column-based-another-table.webp","type":"image\/webp"}],"author":"Sreeram Sreenivasan","twitter_card":"summary_large_image","twitter_creator":"@UbiqBI","twitter_site":"@UbiqBI","twitter_misc":{"Written by":"Sreeram Sreenivasan","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-update-a-column-based-on-another-column-in-sql\/#article","isPartOf":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-update-a-column-based-on-another-column-in-sql\/"},"author":{"name":"Sreeram Sreenivasan","@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc"},"headline":"How To Update a Column Based on Another Column in SQL","datePublished":"2020-11-26T07:22:00+00:00","dateModified":"2026-03-16T04:49:37+00:00","mainEntityOfPage":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-update-a-column-based-on-another-column-in-sql\/"},"wordCount":730,"commentCount":0,"image":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-update-a-column-based-on-another-column-in-sql\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/06\/update-column-based-another-table.webp?fit=720%2C375&ssl=1","keywords":["update column"],"articleSection":["MySQL"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/ubiq.co\/tech-blog\/how-to-update-a-column-based-on-another-column-in-sql\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-update-a-column-based-on-another-column-in-sql\/","url":"https:\/\/ubiq.co\/tech-blog\/how-to-update-a-column-based-on-another-column-in-sql\/","name":"How To Update a Column Based on Another Column in SQL - Ubiq BI","isPartOf":{"@id":"https:\/\/ubiq.co\/tech-blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-update-a-column-based-on-another-column-in-sql\/#primaryimage"},"image":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-update-a-column-based-on-another-column-in-sql\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/06\/update-column-based-another-table.webp?fit=720%2C375&ssl=1","datePublished":"2020-11-26T07:22:00+00:00","dateModified":"2026-03-16T04:49:37+00:00","author":{"@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc"},"description":"Here is how to update a column based on another column in SQL Server, MySQL, PostgreSQL.","breadcrumb":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-update-a-column-based-on-another-column-in-sql\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/ubiq.co\/tech-blog\/how-to-update-a-column-based-on-another-column-in-sql\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-update-a-column-based-on-another-column-in-sql\/#primaryimage","url":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/06\/update-column-based-another-table.webp?fit=720%2C375&ssl=1","contentUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/06\/update-column-based-another-table.webp?fit=720%2C375&ssl=1","width":720,"height":375,"caption":"update column based in another table"},{"@type":"BreadcrumbList","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-update-a-column-based-on-another-column-in-sql\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/ubiq.co\/tech-blog\/"},{"@type":"ListItem","position":2,"name":"How To Update a Column Based on Another Column in SQL"}]},{"@type":"WebSite","@id":"https:\/\/ubiq.co\/tech-blog\/#website","url":"https:\/\/ubiq.co\/tech-blog\/","name":"Ubiq BI","description":"Build dashboards &amp; reports in minutes","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/ubiq.co\/tech-blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc","name":"Sreeram Sreenivasan","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g","caption":"Sreeram Sreenivasan"},"description":"Sreeram Sreenivasan is the Founder of Ubiq. He has helped many Fortune 500 companies in the areas of BI &amp; software development.","sameAs":["https:\/\/www.linkedin.com\/in\/sreeram-sreenivasan\/"],"url":"https:\/\/ubiq.co\/tech-blog\/author\/wordpress\/"}]}},"jetpack_featured_media_url":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/06\/update-column-based-another-table.webp?fit=720%2C375&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/pbGGTT-2d7","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/8501","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/comments?post=8501"}],"version-history":[{"count":3,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/8501\/revisions"}],"predecessor-version":[{"id":10699,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/8501\/revisions\/10699"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/media\/8502"}],"wp:attachment":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/media?parent=8501"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/categories?post=8501"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/tags?post=8501"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}