Question

INFORMATION:

TABLE = giveaway

FORM 1 = id

FORM 2 = username

FORM 3 = userid

FORM 4 = wish

END OF INFORMATION

I am trying to make it filter through duplicate usernames and userids

NOTE: people enter the userid and the username (it is for a giveaway)

can anyone post me some code to do that?

Was it helpful?

Solution

Try this one:

SELECT  `username`,`userid` FROM `giveaway` group by `username` HAVING COUNT(`username`) > 1 UNION SELECT `username`,`userid` FROM `giveaway` group by `userid` HAVING COUNT(`userid`) > 1

OTHER TIPS

drop table test;
/
create table test
(
id number,
username varchar2(20),
userid number,
wish varchar2(40)
);
/
insert into test
values(1,'A',1,'ZXX');

/
insert into test
values(1,'A',1,'YYY');

/
insert into test
values(1,'B',2,'ZXX');
/

SELECT * FROM 
(
SELECT ID ,USERNAME,USERID,COUNT(*) OVER (PARTITION BY USERNAME,USERID) AS CNT
FROM TEST
)
WHERE CNT <2

This will give you unique values

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top