Finally, let's look at how you delete data from your table. Note that when you delete something from MySQL, it is deleted - gone, no more, etc. Unless you use transactions that aren't committed, there is no "undo" feature. This is inherent to all databases, not just MySQL.
Here is the most basic way to delete data from a table:
DELETE FROM usertable;
That will delete all rows from a table, in the say way "SELECT * FROM usertable" will select all rows from a table. DELETE takes both the WHERE and LIMIT clauses, allowing you to construct more complicated statements such as this one:
DELETE FROM usertable WHERE FirstName = 'Bill' LIMIT 3;
Next chapter: MySQL for dummies >>
Databases Introduction Database hierarchy Types of data Date and time Transactions Stored procedures Triggers Views Keys Referential integrity Indexes Persistent connections Temporary Tables Table handlers Round up History MySQL PostgreSQL Oracle Microsoft SQL Server SQL SQL comments Interacting with MySQL Creating tables Making table changes Deleting tables Inserting data Selecting data Extra SELECT keywords Updating data Deleting data MySQL for dummies A working example Multiple WHERE conditions Grouping rows together with GROUP BY MySQL functions Managing indexes Simple text searching using LIKE Advanced text searching using full-text indexes Range matching Working with NULL Default values Using MySQL with PHP Connecting to a MySQL database Querying and formatting Disconnecting from a MySQL database Reading in data Mixing in PHP variables Results within results Advanced formatting Reading auto-incrementing values Unbuffered queries for large data sets: MYSQLI_USE_RESULT phpMyAdmin PEAR::DB Quick PEAR::DB calls Query information Advanced PEAR::DB Impeared performance? SQLite Using SQLite Before you begin Getting started with SQLite 3 Advanced usage: SQLite3::lastInsertRowID() and SQLite3::querySingle() Mixing SQLite and PHP: SQLite3::createFunction() Normalisation Why separate data? So, what is the solution here? Why not separate data? First normal form Second normal form Other normal forms Conclusion Table joins Complex joins Using temporary tables Adjusting the priority queue How to design your tables Picking the perfect data type When MySQL knows best Persistent connections Choosing a table type Transactions MySQL Improved Subselects, views, and other advanced functions Subselects Views Referential integrity Summary Exercises Further reading Next chapter
Table of Contents
Copyright ©2015 Paul Hudson.
Follow me: @twostraws.