Wrox Home  
Search P2P Archive for: Go

  Return to Index  

sql_language thread: How to delete from multiple tables?


Message #1 by "Jake C" <jakeone@b...> on Sun, 27 May 2001 14:27:51
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
: Can anyone tell me the correct syntax for deleting records from multiple
: tables.  I'm using something like the following - but without luck:
:
: DELETE FROM table1, table2, table3 WHERE ID = 12
:
: What am I doing wrong?  In addition, can you use INNER JOINs with DELETE -
: this seemed quite a logical thing to do but it kept returning errors.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

DELETE FROM Table1 WHERE ID = 12
DELETE FROM Table2 WHERE ID = 12
DELETE FROM Table3 WHERE ID = 12

If you have a database that supports cascading deletes (eg SQL Server 2000,
or Access) you could delete the parent record, and have the deletes cascade
down to the child tables (I do not recommend this for production systems)

Cheers
Ken


  Return to Index