Sql updating a table from the same table

Additionally if you forget the WHERE clause altogether, you will update the entire table when you might not intend to.Here is an example where I specified the WHERE clause incorrectly and I updated too many rows: Here I updated Toy Name on two rows, the “Silver Magic” and the “Super Surfer” Toyname rows.

In my examples above I only updated a single column with my UPDATE statement.

To update this single row I can run the following UPDATE statement: the UPDATE statement was able to find the one row in my Toy table that had the misspelled Toy Name.

To update the row that was found I used the “SET” clause of the UPDATE statement, which set the new Toy Name to the correct spelling of “Magic Wand”.

Suppose I wanted to change both the Toy Name and the Price columns.

I can update multiple columns with a single UPDATE statement.

Search for sql updating a table from the same table:

sql updating a table from the same table-21

Leave a Reply

Your email address will not be published. Required fields are marked *

One thought on “sql updating a table from the same table”