MYSQL 常用命令

随机取3条

SELECT * FROM `cookbook` ORDER BY RAND() LIMIT 3;

===============================

删除表中重复数据

DELETE
FROM
    cookbook
WHERE
    cookbook_id NOT IN (
        SELECT
            bid
        FROM
            (
                SELECT
                    min(cookbook_id) AS bid
                FROM
                    cookbook
                GROUP BY
                    cookbook_coding
                    cookbook_coding
            ) AS b
    )

 ===========================

多表删除

DELETE a,aa
FROM
    `cookbook` a,
    `seasonal` aa
WHERE
    a.`thumb_url` = 'http://fz-ggd-1.oss-cn-hangzhou.aliyuncs.com/555'
AND a.`cookbook_id` = aa.`cookbook_id`

================================

posted @ 2016-06-29 23:44  __Rain丶  阅读(173)  评论(0编辑  收藏  举报