Notes MySQL command delete from: Delete record

Source: Internet
Author: User

The delete from command is used to delete data from a table.

Delete from command format: Delete from table name where expression

For example, delete the record numbered 1 in table MyClass:
Mysql> Delete from MyClass where id=1;

Please compare the table changes before and after deleting the data.

Age
FirstName LastName
Peter Griffin 35
Glenn Quagmire 33


The following is an example of PHP code to delete all Lastname= ' Griffin ' records in the "Persons" table:

  1. <?php
  2. $con = mysql_connect("localhost","Peter","abc123");
  3. If (! $con){
  4. Die(' Could not connect: ' . mysql_error());
  5. }
  6. mysql_select_db("my_db", $con);
  7. Mysql_query("DELETE from Persons WHERE lastname= ' Griffin '"); mysql_close($con);
  8. ?>

After this deletion, the table is like this:

Age
FirstName LastName
Glenn Quagmire 33

Notes MySQL command delete from: Delete record

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.