954,560 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

problem deleting a row in table sql

hi guys! i have a problem regarding the queries i coded. my first query is to display the category name, description and maxscore:

SELECT c.cat_name, g.maxscore, g.description
FROM grp_performance
INNER JOIN category c
ON g.cat_id = c.cat_id

the problem is, i don't know how to delete the row in the gp_performance table without deleting the records in the category table. i tried using innerjoin but still it doesn't work. this is part of our thesis project and i really need some help! :(

bhob
Newbie Poster
8 posts since Dec 2008
Reputation Points: 10
Solved Threads: 0
 

This is the model. Adapt to your tables.

delete from grp_performance
where g.id in 
(
SELECT g.id
FROM grp_performance
INNER JOIN category c
ON g.cat_id = c.cat_id
)
smantscheff
Nearly a Posting Virtuoso
1,233 posts since Oct 2010
Reputation Points: 300
Solved Threads: 254
 

g.id? you mean the primary key of grp_performance?

bhob
Newbie Poster
8 posts since Dec 2008
Reputation Points: 10
Solved Threads: 0
 

Yes.

smantscheff
Nearly a Posting Virtuoso
1,233 posts since Oct 2010
Reputation Points: 300
Solved Threads: 254
 

DELETE from grp_performance(TABLE NAME) WHERE g.id IN(PRIMARY KEY);
Try this.

Anuradha Mandal
Junior Poster
122 posts since Sep 2010
Reputation Points: 0
Solved Threads: 10
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: