How To Delete an Existing Row from a Table

Q

How To Delete an Existing Row from a Table? - MySQL FAQs - Understanding SQL INSERT, UPDATE and DELETE Statements

✍: FYIcenter.com

A

If you want to delete an existing row from a table, you can use the DELETE statement with a WHERE clause to identify that row. Here is good sample of DELETE statements:

mysql> INSERT INTO fyi_links (url, id) 
   VALUES ('www.myspace.com', 301);
Query OK, 1 row affected (0.00 sec)

mysql> SELECT id, url, notes, counts FROM fyi_links 
   WHERE id = 301;
+-----+-----------------+-------+--------+
| id  | url             | notes | counts |
+-----+-----------------+-------+--------+
| 301 | www.myspace.com | NULL  |   NULL |
+-----+-----------------+-------+--------+
1 row in set (0.00 sec)

mysql> DELETE FROM fyi_links WHERE id = 301;
Query OK, 1 row affected (0.00 sec)

mysql> SELECT id, url, notes, counts FROM fyi_links 
   WHERE id = 301;
Empty set (0.00 sec)

2007-05-11, 4759👍, 0💬