Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Closed Thread
MySQL delete from 2 tables at once.
Old 05-19-2005, 04:23 PM MySQL delete from 2 tables at once.
OmuCuSucu's Avatar
Vi Veri Veniversum Vivus

Posts: 1,168
Name: Dragos-Valentin
Location: Cluj-Napoca, RO
Trades: 0
Code:
DELETE FROM produse WHERE id_categorie = '$id';
DELETE FROM categorii WHERE id_categorie = '$id';
the $id is the same.
i am building a product catalog and "produse" is the products and "categorii" is the cathegories ... when i delete one cathegorie it must delete all products belonging to it.

how do i combine the two queries in a single one? i am pretty tired and can't think clear now ... but i need it done asap

i'm not interrested in the php solution. need sql solution.

anyone?
__________________
.
» Please remember to add to my Talkupation if you enjoyed my post. Thank you :)
.

Last edited by OmuCuSucu; 05-19-2005 at 04:40 PM.. Reason: code tags
OmuCuSucu is offline
View Public Profile
 
 
Register now for full access!
Old 05-19-2005, 04:32 PM
compmodder26's Avatar
Experienced Talker

Posts: 44
Trades: 0
Quote:
Originally Posted by OmuCuSucu
DELETE FROM produse WHERE id_categorie = '$id';
DELETE FROM categorii WHERE id_categorie = '$id';
Try this:


Code:
DELETE FROM produse, categorii WHERE id_categorie = '$id';
__________________
Buy Cool Univeristy of Kentucky Merchandise at

Please login or register to view this content. Registration is FREE
compmodder26 is offline
View Public Profile Visit compmodder26's homepage!
 
Old 05-19-2005, 04:38 PM
OmuCuSucu's Avatar
Vi Veri Veniversum Vivus

Posts: 1,168
Name: Dragos-Valentin
Location: Cluj-Napoca, RO
Trades: 0
that doesn't work compmodder26... tried that before posting.

Code:
DELETE categorii, produse FROM categorii, produse WHERE categorii.id_categorie = '$id'AND produse.id_categorie = '$id'
this does. found my solution. it was the specifications before FROM and adding table.column in the WHERE clause that i did wrong.

thank for the quick reply anyway i don't have much time for this project and everything matters.

thread can be closed
__________________
.
» Please remember to add to my Talkupation if you enjoyed my post. Thank you :)
.

Last edited by OmuCuSucu; 05-19-2005 at 04:41 PM..
OmuCuSucu is offline
View Public Profile
 
Old 05-19-2005, 11:09 PM
Uche's Avatar
Extreme Talker

Posts: 174
Location: Nigeria/Lagos
Trades: 0
i guess u use Join statement
__________________
Life is just lyke a school where everybody goes to learn one or two thing. the more u school, the more u learn more about school..The more we live our lifes.. the more we learn more about life.

Please login or register to view this content. Registration is FREE
Uche is offline
View Public Profile Visit Uche's homepage!
 
Old 05-20-2005, 01:28 AM
OmuCuSucu's Avatar
Vi Veri Veniversum Vivus

Posts: 1,168
Name: Dragos-Valentin
Location: Cluj-Napoca, RO
Trades: 0
yes, there is a comma between the tables. that is a join.
__________________
.
» Please remember to add to my Talkupation if you enjoyed my post. Thank you :)
.
OmuCuSucu is offline
View Public Profile
 
Closed Thread     « Reply to MySQL delete from 2 tables at once.
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.49430 seconds with 12 queries