Jump to content


Photo

Deleting Something Out Of Mysql


  • Please log in to reply
3 replies to this topic

#1 littlkj5

littlkj5
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 28 June 2006 - 08:54 PM

How do i delete something from the DB through PHP?


#2 sammermpc

sammermpc
  • Members
  • PipPip
  • Member
  • 16 posts

Posted 28 June 2006 - 09:55 PM

Delete DB entries the same way you add them, but with a correspondingly different entry.  Instead of querying the database with an INSERT command, query it with a DELETE.  Check out the manual on mysql queries, the documentation is very complete.

Also check out the php reference on the commands mysql_query, as well as the many other embedded mysql php functions.

#3 SharkBait

SharkBait
  • Members
  • PipPipPip
  • Advanced Member
  • 845 posts
  • LocationMetro Vancouver, BC

Posted 29 June 2006 - 01:42 PM

If your deleting just 1 item from a database, even though there may be only 1 instance of it in the database I would still suggest using LIMIT 1 a the end of the query.

DELETE FROM myTable WHERE id = '4' LIMIT 1;


#4 xyn

xyn
  • Members
  • PipPipPip
  • Advanced Member
  • 779 posts
  • LocationNorthampton

Posted 29 June 2006 - 03:14 PM

The only way of deleting something is the way SharkBait says,

This code below is deleting 1 thing...
DELETE FROM Table WHERE id='1'

This is to delete everything...
TRUNCATE Table





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users