Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with multi-delete

Status
Not open for further replies.

BennySHS

Programmer
Mar 15, 2005
32
DE
Hi there,

i got a tbl_categoie and a tbl_branchen. A Categorie can have N branches.
When I delete a categorie, I want to delte all its branches too, and this in one statement.
I tried the following:

$SQL = "DELETE
tbl_rubriken,
tbl_branchen
FROM
tbl_rubriken,
tbl_branchen
WHERE tbl_branchen.rubrikid = tbl_rubriken.id
AND tbl_rubriken.id = '$rubid' ;";

It works when the categorie has at least one branche, but when the categorie has no branches, it doesn't get deleted.

I've not worked with these mDelte-statements yet and I'm not so experienced in SQL, so I hope you can help me.

Thx a lot,
greets ben
 
This may not be what you need, but i think doing the deleting one after the other may save u some headache...
using php if else statements (if u use php) can also do the trick
 
hi kehers,

thx for your reply!

yes I work with php, but I want to solve this with an multi-delete-statement, because I hate it to make a while-loop and starting dozens other querys. (I think this is not very performant or elegant...)


So I like to now if this is impossible to do, or how do I get it to work ? ^^

thx a lot,
greets ben
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top