SQL Recipes
A FREE cookbook for SQL queries and examples
Register FAQ Search Today's Posts Mark Forums Read

SQL - Questions and Answers Have a SQL question? Post it here. First do a search to see if someone hasn't already answered it.

Go Back   SQL Recipes a FREE cookbook of SQL queries and examples > SQL queries and examples > SQL - Questions and Answers

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread
  #1 (permalink)  
Old 09-12-2007, 01:57 PM
renukaa renukaa is offline
Junior Member
 
Join Date: Sep 2007
Posts: 1
renukaa is on a distinguished road
Post ANY dialect question:

how do we delete redundant entries from a table ?


Can anyone tell me how to write query for deleting redundant entries from a column which is not the primary key of the table, suppose u are given two columns say A & B which contains values X & Y resp. two times in a table then how do we delete both the entries or any one entry.
plz help me i m too confused
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

ANSWER(S):

  #2 (permalink)  
Old 09-19-2007, 10:20 AM
Unregistered
 
Posts: n/a
Default ANY answer. Re: how do we delete redundant entries from a table ?

suppose there is a table named "test" having a column "x" having values:

x
-----
3727
3726
3728
3727
3726

Then the query would be as:
"delete from test where x in(select x from test group by x having count(x)>=2);"

Hope this would solve ur problem....
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Edit/Delete Message Reply With Quote
  #3 (permalink)  
Old 09-20-2007, 05:58 AM
shashi jain shashi jain is offline
Junior Member
 
Join Date: Sep 2007
Posts: 3
shashi jain is on a distinguished road
Lightbulb ANY answer. Re: how do we delete redundant entries from a table ?

suppose there is a table named "temp" having a column "col1" and "col2".

col1 col2
---- ---
abc 100
abc 100
abc 150
xyz 200
xyz 200

then the query would be as:

"delete from temp t where t.col1 in(select t1.col1 from temp t1 where t.rowid< t1.rowid) and t.col2 in(select t1.col2 from temp t1 where t.rowid <
t1.rowid);"

Hope this would solve ur problem....
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

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

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



All times are GMT. The time now is 05:02 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0
Copyright (c) 2006-2008 SQL Recipes

1 2 3 4 5 6 7 8