SQL Update
SQL Update Command allows changing the value of a column or columns. For example if we want to change the price of an item from our items table, we will use update command.
SYNTAX:
Update TableName set column1 = ‘newvalue’, column2 = ‘newvalue’
EXAMPLE:
UPDATE ITEMS SET ItemName = ‘keyboard’
Another Example
UPDATE ITEMS SET ItemName = ‘keyboard’ WHERE ItemID = 2
DESCRIPTION:
UPDATE Command is used for changing values of columns. For instance, we have many products in a table and we have entered product category name for all products wrong. If we want to change it, we can use update command. This command will change all items names to a specified name.
But in most cases, we would not want to change a complete column to one name. In that case, we need to use WHERE Clause with UPDATE Statement. So if you want to changes a specific product name only to a new value, then you need to specify WHERE Clause with Update Command
UPDATE Command is used for changing values of columns. For instance, we have many products in a table and we have entered product category name for all products wrong. If we want to change it, we can use update command. This command will change all items names to a specified name.
But in most cases, we would not want to change a complete column to one name. In that case, we need to use WHERE Clause with UPDATE Statement. So if you want to changes a specific product name only to a new value, then you need to specify WHERE Clause with Update Command
No comments:
Post a Comment