Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Deleting Rows | Updating & Deleting Data
Introduction to SQL

bookDeleting Rows

We can conditionally select and delete rows from a table using the DELETE statement.

Following is the syntax of the DELETE statement:

DELETE FROM table_name
WHERE condition;

The DELETE statement selects rows from table_name based on a condition and deletes them.

Example: Removing Graduated Students

Consider a table students with the following columns name, age, grade, score, and graduation_year.

We would like to delete all the rows from the table where the graduation_year is less or equal to 2024, since those students have already graduated and we no longer want to retain their data.

This can be done using the following query:

DELETE 
FROM students 
WHERE graduation_year <= 2024;

Demonstration:

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 5. ChapterΒ 5

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

Suggested prompts:

Ask me questions about this topic

Summarize this chapter

Show real-world examples

Awesome!

Completion rate improved to 1.72

bookDeleting Rows

Swipe to show menu

We can conditionally select and delete rows from a table using the DELETE statement.

Following is the syntax of the DELETE statement:

DELETE FROM table_name
WHERE condition;

The DELETE statement selects rows from table_name based on a condition and deletes them.

Example: Removing Graduated Students

Consider a table students with the following columns name, age, grade, score, and graduation_year.

We would like to delete all the rows from the table where the graduation_year is less or equal to 2024, since those students have already graduated and we no longer want to retain their data.

This can be done using the following query:

DELETE 
FROM students 
WHERE graduation_year <= 2024;

Demonstration:

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 5. ChapterΒ 5
some-alt