Update Data in Columns

14 February 2012 By Praveen Macherla 193 views No Comment
0 Flares Twitter 0 Facebook 0 Google+ 0 0 Flares ×

UPDATE statement is used to update existing data in database tables. It can be used to change values of single row, group of rows or even all rows in a table. In MySQL, the SQL UPDATE statement form is as below:

UPDATE table_reference SET col_name1={expr1|DEFAULT} [, col_name2={expr2|DEFAULT}] …
[WHERE where_condition]
[ORDER BY ...]
[LIMIT row_count]

The SET clause indicates which columns to modify and the values they should be given. Each value can be given as an expression or the keyword DEFAULT to set a column explicitly to its default value.

The WHERE clause specifies which record or records that should be updated. If you omit the WHERE clause, all records will be updated!

If the ORDER BY clause is specified, the rows are updated in the order that is specified. The LIMIT clause places a limit on the number of rows that can be updated.

Tags: , ,