i

PHP Tutorial

MySQL Commands-Deleting And Updating The Data

If you want to delete any record from the database you can use DELETE statement. It is very helpful for managing a website where a customer deletes his account and for some tables you might need to delete his records.

Syntax : DELETE FROM table_name WHERE column_name = value;

For example: DELETE FROM Visitors WHERE visitor_id = 2;

There might be some cases, when a user has entered a wrong value, or he want to change some data like email or phone number etc. For those cases, you can update the records in SQL using UPDATE statement.

Syntax: UPDATE table_name SET column1 = value, column2 = value,.. WHERE column_name = value

For example: A user wants to update his email address then you can use below statement.

UPDATE Visitors SET email = ‘Paul999@example.com’ WHERE name = ‘Paul’;