PHP School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a PHP Expert!

Join 307,168 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,561 people online right now. Registration is fast and FREE... Join Now!




deleting using subqueries

 

deleting using subqueries

pretender19

12 Jan, 2009 - 09:35 PM
Post #1

New D.I.C Head
*

Joined: 23 Dec, 2008
Posts: 36


My Contributions
im doing a search form using checkboxes... if the user check the talent skills "singing" then i need to delete all the rows in the talents table where talent skills is not equal to singing..
the problem is that there are 2 tables. the talents table and the talents_skills table.
The talents_skills table stores all the talent's skills by using ID.
i wont include the connections in the code.
CODE

if ($_POST['cbskills']!= "")
{
foreach ( $_POST['cbskills'] as $value ) {

$query = "DELETE from talents
WHERE NOT IN(SELECT * FROM talents_skills WHERE talents_skills.ID= talents.ID and skillsname= '$value')";
mysql_query($query);
}


i cannot delete the talents that have no singing skills.all talents are still there.
pls help me.. i know this is just a beginners problem..
just for added info,, the talents table store the talents info except his skills.
his skills are stored in the talents_skills table using his ID and the skillsname.
i put his skills to another table because a talent can have many talents. he can sing, dance, etc..
thank you in advance..

User is offlineProfile CardPM
+Quote Post


Posts in this topic

Fast ReplyReply to this topicStart new topic

Time is now: 11/21/09 06:37PM

Live PHP Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month