Skip to content
January 14, 2011 / doganay

DELETE DUPLICATE ROWS (BASED ON ONE COLUMN)

, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Hi,

You can delete duplicate rows in this way:

For example, mycolumn is the column that you base on. And here are some records:

mycolumn

1 …

1 …

1 …

2 …

2 …

DELETE FROM mytable
WHERE ROWID NOT IN (SELECT MAX (ROWID) FROM mytable GROUP BY mycolumn) ;

commit;

after running that query, you’ll see our table like this:

1 …

2 …

you see, duplicate records are gone.

Try and pray 🙂

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: