List:General Discussion« Previous MessageNext Message »
From:Martin Ramsch Date:August 29 1999 12:33am
Subject:Re: i have a problem with mysql,
View as plain text  
On Sun, 1999-09-29 01:13:56 +0200, Benachenhou Sidahmed wrote:
> the problem is that i create two tables entreprise and type that are
> joined by a field so when i must delete an entreprise i must delete
> from type too, so please tell me how to delete from tables that are
> joined, i tried delete from entreprise, type where
> entreprise.id=type.id, but it doesn't work [...]

Chapter "18.16 Deleting rows from related tables" of the MySQL manual
describes a work-around for this problem.  It basically says to
1st, find the set of columns you want to delete using a normal
     SELECT statement and store this result set, and
2nd, work with two seperate DELETE statements:
       DELETE FROM table1 WHERE id IN (stored_result_set);
       DELETE FROM table2 WHERE id IN (stored_result_set);

Regards,
  Martin
-- 
Martin Ramsch <m.ramsch@stripped> <URL: http://home.pages.de/~ramsch/ >
PGP KeyID=0xE8EF4F75 FiPr=52 44 5E F3 B0 B1 38 26  E4 EC 80 58 7B 31 3A D7
Thread
i have a problem with mysql,benachenhou sidahmed29 Aug
  • Re: i have a problem with mysql,Martin Ramsch29 Aug