Should this delete all records in my SQL table?
<?php
$con = mysql_connect("localhost","bikemap","pedalhard");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("test", $con);
mysql_query("DELETE * FROM gpsdata");
mysql_close($con);
?>
Delete Data From a MySQL Table Using MySQLi and PDO. Notice the WHERE clause in the DELETE syntax: The WHERE clause specifies which record or records that should be deleted. If you omit the WHERE clause, all records will be deleted!
There is no delete() function in PHP. If you need to delete a file, look at the unlink() function.
The DELETE
syntax doesn't allow a star between DELETE
and FROM
. Try this instead:
mysql_query("DELETE FROM gpsdata");
You might want to check out MySQL's Truncate command. That should remove all records easily.
DELETE
differs from Truncate
. But if your use case is simple, go to any one.
Truncate
DELETE
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With