The Queries in this page solved at the library database. It is a sample database generated by randomly records. You can download it from the link. You will see more than 500 examples in the future. You can filter from the search panel above by selecting sql statements. I hope you will like it

SQL Delete Examples

1-) Delete the student whose number 5.

Solution 1)

Delete from students 
       where studentId = 5


ETİKETLER

Delete - Where -
2-) Delete all books

Solution 1)

Delete from books


ETİKETLER

Delete -
3-) Delete all borrows

Solution 1)

Delete from borrows


ETİKETLER

Delete -
4-) Delete the books, number of pages between 50 and 100 pages.

Solution 1)

Delete from books 
       where pageCount between 50 and 100

Solution 2)

Delete from books 
       where pagecount<=100 and pagecount>=50


ETİKETLER

Delete - Where -
5-) Delete students who do not read books.

Solution 1)

Delete from students 
where studentId not in 
	(Select studentId from borrows)


ETİKETLER

Delete - Where - Sub Query -
6-) Delete the students whose name is Gray

Solution 1)

Delete from students 
       where name = 'Gray'


ETİKETLER

Delete - Where -
7-) Delete students whose name is Gray and surname is King

Solution 1)

Delete from students 
       where name = 'Gray' and surname = 'King'


ETİKETLER

Delete - Where - Multi Condition -
8-) Delete students who have read less than 5 books.

Solution 1)

Delete from students 
where studentId in (Select studentId from borrows 
                group by studentId 
				having count(*)<5)


ETİKETLER

Delete - Where - Group By - Having - Sub Query -
Library Database
Database