How to Update Multiple Columns

Save

Structured Query Language (SQL) is used to select, retrieve, add and delete data within a database (a collection of related tables). You can update one or more columns within the tables of your database in your SQL statement, setting the values of your fields to what you want them to contain. By using the WHERE clause, you can specify which fields you want to update and keep from updating all your records unintentionally.

  • Use the following SQL syntax to update the content in multiple columns in your database:

    UPDATE Table

    SET Col1 = value, Col2 = value

    WHERE Col5 = value

  • Replace "Table" with the database table you want to update. For example, to update the table, "STUDENTS," you would add the following:

    UPDATE Students

  • Replace "Col1" and "Col2" with the column names (fields) you want to update. For example, to update the columns "FirstName," "LastName" and "Address," you would add the following:

    SET FirstName = value, LastName = value, Address = value

    (or)

    SET Students.FirstName = value, Students.LastName = value, Students.Address = value

  • Replace "Col5" after the WHERE clause and "value" with the matching column. For example, to only update the column where the student's last name matches "Dodsworth," you would add:

    WHERE LastName = 'Dodsworth'

    (or)

    WHERE Students.LastName = 'Dodsworth'

References

Promoted By Zergnet

Comments

You May Also Like

Related Searches

Check It Out

Geek Vs Geek: Robot battles, hoverboard drag race, and more

M
Is DIY in your DNA? Become part of our maker community.
Submit Your Work!