GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • CODESCRACKER
  • Python
  • Java
  • C++
  • JavaScript
  • SQL
  • Quiz
  • C
  • C#
  • HTML
  • CSS
  • PHP
  • Networking
  • Operating System

This view

  • Original page
  • New address

GeezerVison is showing codescracker.com — Update Existing Records in SQL

  • SQL Tutorial
  • SQL Tutorial
  • SQL Display Data
  • SQL Update Records
  • SQL Delete Record
  • SQL Alter Table
  • SQL Join Tables
  • SQL Auto Increment
  • SQL Drop Table/Database
  • Computer Programming
  • Learn Python
  • Python Keywords
  • Python Built-in Functions
  • Python Examples
  • Learn C++
  • C++ Examples
  • Learn C
  • C Examples
  • Learn Java
  • Java Examples
  • Learn C#
  • Learn Objective-C
  • Web Development
  • Learn HTML
  • Learn CSS
  • Learn JavaScript
  • JavaScript Examples
  • Learn PHP

Update Existing Records in SQL

In this post, you will learn how to update the record of a table. When I say "update the record," I mean "update the row." Since each row contains one or more columns, indirectly, it is about to update the column values of any specific rows.

To achieve this task, SQL provides the UPDATE statement. Here is the general form of the SQL UPDATE statement that can be used to update the records of a table.

UPDATE tableName
SET column1 = newValue1, column2 = newValue2, ..., columnN = newValueN
WHERE condition;

The WHERE clause is required to be included while updating the record of a table, until and unless you want to update all the records.

Now let me create a SQL query that will update the record of a table named "customer."

UPDATE customer
SET email='[email protected]'
WHERE id = 3;

After executing the above SQL query, the column "email" will be updated with "[email protected]." Since I used the WHERE clause to only update the record whose id value is equal to 3, therefore, only that particular row will be updated.

If you need to update only one record in a table, then always specify the value of the primary key. Otherwise, if you want to update multiple records, then you can choose any other condition, like to update all records whose city is "Austin," then use the following SQL query:

UPDATE customer
SET email='[email protected]'
WHERE city='Austin';

SQL Online Test


« Previous Topic Next Topic »
Practice Quizzes

Test your programming and computer science knowledge with interactive MCQs and topic-based quizzes.

All Quizzes SQL Quiz Python Quiz Java Quiz C++ Quiz
Popular Topics

Explore the most popular programming and computer science tutorials on CodesCracker.

Python Tutorial Java Tutorial C++ Tutorial SQL Tutorial JavaScript Tutorial HTML Tutorial CSS Tutorial Computer Networking
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.