Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Getting Started with MariaDB

You're reading from   Getting Started with MariaDB Explore the powerful features of MariaDB with practical examples

Arrow left icon
Product type Paperback
Published in Jun 2015
Publisher
ISBN-13 9781785284120
Length 140 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Daniel Bartholomew Daniel Bartholomew
Author Profile Icon Daniel Bartholomew
Daniel Bartholomew
Arrow right icon
View More author details
Toc

Table of Contents (11) Chapters Close

Preface 1. Installing MariaDB 2. Configuring MariaDB FREE CHAPTER 3. Securing MariaDB 4. Administering MariaDB 5. Using MariaDB – Databases and Tables 6. Using MariaDB – Inserting, Updating, and Deleting 7. Using MariaDB – Retrieving Data 8. Maintaining MariaDB A. MariaDB Next Steps
Index

Using DELETE


Just as data sometimes needs to be updated, sometimes it also needs to be removed from a database table. People get new jobs, products are discontinued, and so on. When the time comes to remove something from a table in our database, we use the DELETE command. The basic syntax is as follows:

DELETE FROM <table_name> [WHERE <where_conditions>];

As with UPDATE statements, the WHERE part of a DELETE statement is optional, but if we leave it off, the command will delete every row in the table, which is even more catastrophic than leaving off the WHERE part in an UPDATE statement, if such a thing is possible. Make it a habit to always include it.

As an example, let's delete the Spencer Kimball employee:

DELETE FROM employees
WHERE givenname="Spencer" AND surname="Kimball"; 

As with the UPDATE examples, the WHERE clause is looking up the rows to delete by givenname and surname. A more precise method is to first look up the record to discover its primary key, and then to...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image