SQL Update

To update data in a SQL table, you can use the UPDATE command. This command allows you to modify existing data in one or more rows of a table.

Here is an example of how to use the UPDATE command:

UPDATE customers
SET email = '[email protected]'
WHERE name = 'John Smith';
Source‮figi.www:‬tidea.com

In this example, we are updating the email column in the customers table for the row where the name column is 'John Smith'. The SET keyword is used to specify the new value of the column, and the WHERE keyword is used to specify which row(s) to update based on a condition. In this case, we are updating the email to '[email protected]' only for the row(s) where the name column equals 'John Smith'.

You can update multiple columns at once by separating the column and value pairs with commas, like this:

UPDATE customers
SET email = '[email protected]', phone = '555-4321'
WHERE name = 'John Smith';

This will update the email and phone columns in the customers table for the row(s) where the name column is 'John Smith'.

If you omit the WHERE clause, the UPDATE command will modify all rows in the table. Be careful when using this syntax, as it can result in unintended changes to your data. Always specify a condition to ensure that you only update the rows that you intend to modify.