There is a table of the form:

a|b|c 

How to leave only those lines where the value "a" occurs more than once?

UPD: a | b | c are three columns, columns b and c are always unique and have different values, and the value of column “a” may occur several times

    1 answer 1

    Let the table be called tbl , and contain three columns a , b and c . Then to solve the problem, you can proceed as follows

     DELETE tbl FROM tbl JOIN ( SELECT a, b, c FROM tbl GROUP BY a HAVING COUNT(*) <= 1 ) AS t ON tbl.a = ta AND tbl.b = tb AND tbl.c = tc 
    • I think that the value of "a" occurs more than once - this is a | a | b ... But this is a question for the author - splash58
    • I apologize if I didn’t really express myself) a | b | c - these are three columns, columns b and c always have different values, but the value of column "a" can occur several times, i.e. Grouping fails as I understand it - Vladislav Golovlev
    • @ Vladislav Golovlev, it will turn out. Corrected the answer. - cheops