SQL Step-by-Step (7) Update records

Source: Internet
Author: User

Update records

The UPDATE statement is used to update or alter a record that matches a specified condition, which is implemented by constructing a where statement. The statement format is as follows:

Update "TableName"

Set "ColumnName" = "NewValue" [, "nextcolumn" = "newvalue2" ...]

where "ColumnName" OPERATOR "value" [and|or "column" OPERATOR "value"];

[] = optional

Here's an example to illustrate:

Update Phone_book

Set Area_code = 623

where prefix = 979;

The above statement is in the Phone_book table, and the Area_code is set to 623 in the prefix=979 row.

Update Phone_book

Set last_name = ' Smith ', prefix=555, suffix=9292

where last_name = ' Jones ';

And the above statement is in Phone_book, in last_name= ' Jones ' line will last_name set to ' Smith ', prefix is 555, suffix is 9292.

Update employee

Set age = Age+1

where First_name= ' Mary ' and last_name= ' Williams ';

This statement is in the employee table, in the First_name= ' Mary ' and last_name= ' Williams ' line will be age plus 1.

As with each lesson, you should do the following exercises after completing this tutorial:

1 because Jonie Weber has married Bob Williams, it needs to update its last name to Weber-williams.

2 Dirk Smith's birthday is today, so his age should increase by 1.

3 All secretaries are called "Administrative Assistant". So change all the title headings accordingly.

Just do these few exercises, do not be careless.







Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.