If this is your first visit, be sure to check out the FAQ by clicking the link above.
You may have to register before you can post: click the register link above to proceed.
To start viewing messages, select the forum that you want to visit from the selection below.
i want to clear from my db the doubles and trebles submisions and keep a unique.my db looks like:
a.a code lastname firstname phone
----------------------------------------------------
1 101 smith john 23452345
2 101 smith john 23452345
3 123 black mary 57645756
4 654 white peter 45634564
i want to look like
a.a code lastname firstname phone
----------------------------------------------------
1 101 smith john 23452345
3 123 black mary 57645756
4 654 white peter 45634564
Location: The extremely Royal borough of Kensington, London
Posts: 778
Oracle 9i,
delete from table
where NOT (rowid = (select min(rowid) from table group by KEY));
KEY is defined as a candidate key that is not enforced.
__________________
Bessie Braddock: Winston, you are drunk!
Churchill: And Madam, you are ugly. And tomorrow, I'll be sober, and you will still be ugly.
message returned: Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
The statement has been terminated.
Location: The extremely Royal borough of Kensington, London
Posts: 778
Select distinct columns into #temp from tableA
delete from tableA
insert into tableA select * from #temp
drop table #temp
alter table tableA add primary key (columns)
__________________
Bessie Braddock: Winston, you are drunk!
Churchill: And Madam, you are ugly. And tomorrow, I'll be sober, and you will still be ugly.
DELETE FROM table
WHERE EXISTS (SELECT *
FROM table AS b
WHERE b.id < table.id
AND b.code = table.code
AND b.lastname = table.lastname
AND b.firstname = table.firstname
AND b.phone = table.phone)
Note that I used the php tag to get a monospaced font, this is just standard SQL-92 syntax that should run on any SQL based product.