MySQL Forums
Forum List  »  Newbie

DELETE rows?
Posted by: Shah Sahab
Date: June 15, 2010 08:53PM

Hi, I am kinda new to mysql. Here is my question:

Let's say I have a table with two cols, id and number. Some of the ids are duplicated in two different rows (max. two rows). For a given such id I would like to delete the row with greater value of number. Can I write a query or multiple queries to do something like that, or I will have to write a php code to do that.

Here is the sample data:

"id1", 20
"id2", 1
"id2", 3 <- need to delete this
"id3", 4
"id4", 1
"id3", 6 <- need to delete this

Any guru out there?

Options: ReplyQuote


Subject
Written By
Posted
DELETE rows?
June 15, 2010 08:53PM
June 15, 2010 10:38PM
June 15, 2010 11:23PM
June 16, 2010 02:29AM
June 16, 2010 07:44AM
June 17, 2010 10:07PM
June 17, 2010 11:40PM
June 18, 2010 09:43AM
June 18, 2010 10:26AM
June 19, 2010 07:26AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.