phpbar.de logo

Mailinglisten-Archive

[php] Dringend: SQL-Statement gesucht!

[php] Dringend: SQL-Statement gesucht!

Norbert Pfeiffer php_(at)_phpcenter.de
Tue, 26 Jun 2001 01:12:40 +0200


Hi Christian,

nachdem wir per PM das 'Environment' geklaert haben,
hier die Loesung zum Deleten ueber mehrere Tabellen:

1. Query:
---------
SELECT count(*)
FROM
mail_body AS BY,
mail_idx  AS IX
WHERE
IX.message_body = BY.body_id AND
IX.message_deleted = 'Y' AND
BY.body_deleted = 'Y';

zeigt Dir, ob ueberhaupt was zu loeschen ist.


2. Query:
---------
SELECT DISTINCT BY.body_id
FROM
mail_body AS BY,
mail_idx  AS IX
WHERE
IX.message_body = BY.body_id AND
IX.message_deleted = 'Y' AND
BY.body_deleted = 'Y';

liefert Dir ein Array, der ID's zu 1. -> $IDs
Daraus bastelt Du Dir:


3. Query:
---------
$query = "DELETE FROM mail_body WHERE body_id = ";
$query .= implode($IDs, ' OR body_id = ');

zum Entfernen der Saetze in 'mail_body'


4. Query:
---------
$query = "DELETE FROM mail_idx WHERE body_id = ";
$query .= implode($IDs, ' OR body_id = ');

zum Entfernen der Saetze in 'mail_idx'

So,
nun darfst Du das bissel PHP drumrum machen... ;-)


m.b.G.  Norbert
______________________
normal:   02292-681769
notfall:  0177-2363368
----------------------
e.o.m.





php::bar PHP Wiki   -   Listenarchive