| SQL - Questions and Answers Have a SQL question? Post it here. First do a search to see if someone hasn't already answered it. |
|
||||||
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread |
|
|||
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 ![]() |
|
|||
|
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.... |
|
|||
|
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.... |
![]() |
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|