hello is this how u do a delete query from mysql table i need to delete it depending on id number so if user enters id 10 it needs to delete the all the rows that have id 10 from any table which has that id.. thanks

$query = "DELETE
tbl_name[.*] [, tbl_name[.*]]
FROM tom, ron, chris, bert
WHERE id ='$value'";
$result = mysql_query($query);

hello is this how u do a delete query from mysql table i need to delete it depending on id number so if user enters id 10 it needs to delete the all the rows that have id 10 from any table which has that id.. thanks

$query = "DELETE
tbl_name[.*] [, tbl_name[.*]]
FROM tom, ron, chris, bert
WHERE id ='$value'";
$result = mysql_query($query);

using your data, assuming 'tom', 'ron', 'chris' and 'bert' are table names.

DELETE tom.*, ron.*, chris.*, bert.*
FROM tom, ron, chris, bert
WHERE id = '$value';

Sam

In syntax "markup" anything in angle brackets, < >, is a required field, anything inside brackets [ ], is optional. So DELETE FROM <table> means that you must have something where it says <table>, ie., DELETE FROM someTable .

That said the query format is

DELETE FROM <table > [, table [...]] [WHERE <col> = <value> [LIMIT <offset>[,<number>]

Meaning that you can do DELETE FROM someTable, someSecondTable WHERE row = 3 LIMIT 0,2 Which would delete everything from someTable and someSecondTable where row is equal to 3. Or I could simply do, DELETE FROM someTable WHERE row = 3

This article has been dead for over six months. Start a new discussion instead.