The Sql Delete Statement – Query Examples

The Sql Delete Statement

The Sql Delete Statement

  • The Sql Delete Statement is used to remove records from tables.
  • If we don’t write conditions, the tables all records are removed
  • It’s the one of DML(Data Manupulation Language) codes

The Sql Delete Syntax

or

or only

Not: We can use all condition types where used on the select where  clause:

TO DOWNLOAD THE SAMPLE LİBRARY DATABASE CLICK

SQL Delete From Examples on Library Database

Sample 1: Delete the book where book_id equal 20

Result Of Query:1 row(s) affected.

Not: When we execute the query we can take the error “The DELETE statement conflicted with the REFERENCE constraint FK——“.If the tables have relations then we take the error. We must delete the book’s borrows first. Then we can delete the book.

Sample 2: Delete the students of 10A class

Result Of Query:  23 row(s) affected.

Sample 3: Delete the Borrows where taken date between 10.10.2000 and 01.01.2002

Result Of Query:  1156 row(s) affected.

Sample 4: Delete all Autors

Not: AutorId resumes from where It left off

Method 2

Not: AutorId starts over

Sample 5: Delete the borrows of the student named John

Result Of Query:  51 row(s) affected.

Sample 6: Delete students where has not read books

Result Of Query:  1 row(s) affected.

YOU MAY WANT TO SEE OUR ALL EXAMPLES PAGE, THEN CLICK HERE

About the author

admin

Leave a Comment

%d bloggers like this: