3

Possible Duplicate:
How to delete from multiple tables in MySQL?

i have a SQL query as follows

$deletebills=mysql_query("delete from bills,billsitems,cashier_trans where bills.bills_ID=billsitems.billsItems_BillItemSerial and bills.bills_ID=cashier_trans.cashier_trans_DocId and bills.bills_ID='".$_REQUEST['bills_ID']."'");

The Error :

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'where bills.bills_ID=billsitems.billsItems_BillItemSerial and bills.bills_ID=cas' at line 1

how can i solved it.

Community
  • 1
  • 1
  • You're missing a FROM clause. http://stackoverflow.com/questions/2567976/deleting-rows-from-multiple-tables-in-mysql – Prash Nov 26 '12 at 16:34
  • Use DELETE FROM ... USING. And be careful to SQL Injection your code is not secured at all this is scary. – Bgi Nov 26 '12 at 16:35
  • @Brendan Long but your link not solved !! – Khalid Almallahi Nov 26 '12 at 16:43
  • @Prash i am use from clause, see my code plz `delete from bills,billsitems,cashier_trans where bills.bills_ID=billsitems.billsItems_BillItemSerial and bills.bills_ID=cashier_trans.cashier_trans_DocId and bills.bills_ID='".$_REQUEST['bills_ID']."'` – Khalid Almallahi Nov 26 '12 at 16:45
  • The problem is that you're trying to delete from multiple tables at once, and the question I linked to gives the solution (do the queries separately). What you're trying to do isn't possible in MySQL. – Brendan Long Nov 26 '12 at 16:53
  • So how can edit on my code what can i do ?? – Khalid Almallahi Nov 26 '12 at 16:56

1 Answers1

4

You can't delete from all tables at once. You must delete from each table. MySql Delete