数据库,表查询与删除

表查询

查询postcode表中level1列中含有1的
SELECT * FROM postcode WHERE level1 LIKE "%1%";

查询jxjs_href表中court_name列中等于[]的
SELECT * FROM jxjs_href t WHERE t.court_name = '[]'

查询jxjs_href表中index列中大于等于10小于等于20的
SELECT * FROM jxjs_href t WHERE t.index >=10 AND t.index<=20

表删除

删除postcode表中level1列中含有1的
DELETE FROM postcode WHERE level1 LIKE "%1%";

删除jxjs_href表中court_name列中等于[]的
DELETE FROM jxjs_href WHERE court_name = "[]"

数据库,表查询与删除_第1张图片

mysql单表删除重复数据并且只保留一条

参考于:https://blog.csdn.net/n950814abc/article/details/82284838

//去重

DELETE
FROM
    jxjs_href                                                         -- jxjs_href表名
WHERE
    `index` NOT IN (                                                  -- index字段(索引)
        SELECT
            dt.minno                                          -- 这点不用改
        FROM
            (
                SELECT
                    MIN(`index`) AS minno             -- MIN :重复数据中index最小的
                FROM
                    jxjs_href
                GROUP BY
                    court_href
            ) dt
    )
数据库,表查询与删除_第2张图片
单表去重

你可能感兴趣的:(数据库,表查询与删除)