duplicatesmysql-workbenchsql-deletedelete-operatormysql-error-1241

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


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


Solution

  • 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
    );