Sonzaschool
Rudi

Sekondari ya Kawaida · Kidato cha Pili · Amali · Electronics and Computer

Computer Programming

Implementing updating and deletion of data in a database

takriban dakika 3 kusoma

Majadiliano
Mada za sehemu hiiLinking forms to databases for interactive web applicationsMada 3

Updating and deleting data are two fundamental operations that allow us to modify or remove existing records in a database. After learning how to insert and retrieve data, we now focus on how to change (update) or remove (delete) information when needed — for example, correcting a customer's phone number or removing an out-of-stock item from an inventory.

The UPDATE statement is used to modify existing records in a table. It changes the values of specified columns for rows that meet a certain condition.

Basic Syntax

UPDATE table_name
SET column1 = new_value1, column2 = new_value2
WHERE condition;
  • UPDATE table_name — specifies which table to modify
  • SET column = new_value — defines the column(s) to change and their new values
  • WHERE condition — identifies which row(s) to update; without this, ALL rows would be updated!

Worked Example

Consider a table called students at Mwenge Secondary School:

idnamephonestream
1Amina Rajabu0755123456Science
2Emmanuel John0655789012Arts
3Fatuma Hamisi0713234567Science

Amina changes her phone number. The UPDATE query:

UPDATE students
SET phone = '0689123456'
WHERE id = 1;

After this update, Amina's record now shows 0689123456.

If we want to change all Science stream students to "Science A":

UPDATE students
SET stream = 'Science A'
WHERE stream = 'Science';

Jinsi utakavyotathminiwaTathmini ya mchakato · Tathmini ya matokeo · Tathmini ya maarifa

Tathmini ya mchakato

  • Create HTML forms to update database records using UPDATE

Tathmini ya matokeo

Interactive forms that allow users to modify or delete database records (e.g.,

Tathmini ya maarifa

Detailed knowledge of:

Method used: The student should explain how to

  • write UPDATE

Swali

What is the correct SQL syntax to update a customer's phone number in a table named customers where the customer ID is 5?

Ingia ili kuwasilisha jibu lako na lihesabiwe katika umahiri wako.

Ingia ili kufanya mazoezi

Mwalimu

Umekwama? Niulize chochote kuhusu mada hii.

Ingia ili kumuuliza Mwalimu wa AI wa Sonza kuhusu swali hili.

Ingia ili kuuliza

Majadiliano

Hakuna maswali bado

Ingia ili kuuliza
Inapakia majadiliano…