How To Use Existing Values in UPDATE Statements?
Page 1 of 1
How To Use Existing Values in UPDATE Statements?
If a row matches the WHERE clause in a UPDATE statement, existing values in this row can be
used in expressions to provide new values in the SET clause. Existing values are represented by
columns in the expressions. The tutorial exercise below shows a good example:
UPDATE fyi_links SET id = 1000 + id, counts = id*2
WHERE id >= 250;
3 rows updated.
SELECT * FROM fyi_links WHERE id >= 250;
ID URL NOTES COUNTS CREATED
----- ------------------------ ------------ ------- ---------
1250 Retail Sales.com Wrong URL 500 07-MAY-06
1260 Recruiting.com Wrong URL 520 07-MAY-06
1270 Payroll.com Wrong URL 540 07-MAY-06
used in expressions to provide new values in the SET clause. Existing values are represented by
columns in the expressions. The tutorial exercise below shows a good example:
UPDATE fyi_links SET id = 1000 + id, counts = id*2
WHERE id >= 250;
3 rows updated.
SELECT * FROM fyi_links WHERE id >= 250;
ID URL NOTES COUNTS CREATED
----- ------------------------ ------------ ------- ---------
1250 Retail Sales.com Wrong URL 500 07-MAY-06
1260 Recruiting.com Wrong URL 520 07-MAY-06
1270 Payroll.com Wrong URL 540 07-MAY-06
Similar topics
» How To Update Values in a Table?
» How To Count Duplicated Values in a Column?
» What Are DDL Statements?
» How To Use SQL Statements in PL/SQL?
» How To Run SQL Statements through the Web Interface?
» How To Count Duplicated Values in a Column?
» What Are DDL Statements?
» How To Use SQL Statements in PL/SQL?
» How To Run SQL Statements through the Web Interface?
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
Sun Jan 31, 2010 12:35 am by Micheal
» Accessing tables of other users in SQL
Sun Jan 31, 2010 12:34 am by Micheal
» Grouping commands in SQL
Sun Jan 31, 2010 12:32 am by Micheal
» Operations on Result Sets in SQL
Sun Jan 31, 2010 12:31 am by Micheal
» Subqueries in SQL
Sun Jan 31, 2010 12:30 am by Micheal
» Joining Relations in SQL
Sun Jan 31, 2010 12:28 am by Micheal
» Delete comand in SQL
Sun Jan 31, 2010 12:27 am by Micheal
» Update command in SQL
Sun Jan 31, 2010 12:26 am by Micheal
» Insert command in SQL
Sun Jan 31, 2010 12:23 am by Micheal