Error Code: 1241. Operand should contain 1 column(s) when delete duplicate

45 views Asked by At

delete from dupp where empno in (select empno,count() from dupp group by empno having count()>1)

Error Code: 1241. Operand should contain 1 column(s) what can i do to slove this ??/

i want to delete duplicate and please to help me

1

There are 1 answers

4
Tim Biegeleisen On BEST ANSWER

The error is stemming from the subquery whose select contains 2 things, the empno and the count. You don't even need to be selecting the count, so remove it and the query should work:

DELETE
FROM dupp
WHERE empno IN (
    SELECT empno
    FROM (
        SELECT empno FROM dupp GROUP BY empno HAVING COUNT(*) > 1
    ) t
);