SQL UPDATE

SQL UPDATE

The UPDATE command is used to change or update data values in a table.

UPDATE all rows one column

Syntax

UPDATE <TableName> SET <ColumnName 1>=<Expression> or <Value>

Example

UPDATE EMPLOYEE SET COUNTRY="INDIA";

UPDATE all rows more than one column

Syntax

UPDATE <TableName> SET <ColumnName 1>=<Expression> or <Value>, 
<ColumnName 2>=<Expression> or <Value>

Example

UPDATE EMPLOYEE SET COUNTRY="INDIA", STATE="MH"

UPDATE records conditionally

Syntax

UPDATE <TableName> SET <ColumnName 1>=<Expression> or <Value>,
<ColumnName 2>=<Expression> or <Value> WHERE <Condition>

Example

UPDATE EMPLOYEE SET COUNTRY="INDIA", STATE="MH" WHERE ID LIKE '123%'

,

Leave a Reply