Simple repetitive data handling MySQL

1, a lookup table columns duplicate the amount of data:
for example: information to identify duplicate student number (XH) of

SELECT
    a.id,
    a.XH,
    a.XZBH,
    a.BYF,
    COUNT(1) AS c
FROM
    `t_sdrs_xsxj` AS a
GROUP BY
    XH
HAVING
    c > 1;

2, look-up table dataset of a column to re-:

For example: deduplication student number (XH)

SELECT * FROM t_sdrs_xsjbxx ORDER BY xh;

or

SELECT DISTINCT xh,XM,XB FROM v_xs_jbxx;

3, to duplicate data, duplicate data is deleted, leaving a

E.g:

DELETE FROM user
    WHERE id NOT IN (
        SELECT temp.min_id FROM (
            SELECT MIN(id) min_id FROM user
                GROUP BY name,age
            )AS temp
    );

There are other methods to weight.

Guess you like

Origin www.cnblogs.com/yuezc/p/12172963.html