MySQL将一个表的数据插入到另外一张表中

需求:将A表中指定查询条件的数据,插入到B表中。

INSERT INTO ap_base_categories (
    category_name,
    category_id,
    parent_id,
    `level`,
    tree,
    site_code,
    created_at,
    is_leaf,
    platform
) SELECT
    category_name,
    category_id,
    parent_id,
    `level`,
    tree,
    site_code,
    created_at,
    is_leaf,
    platform
FROM
    ap_categories
WHERE
    platform = 1
AND site_code = 'MY';

注意:字段要一一对应。

posted @ 2022-07-23 17:29  在斑马线上散布  阅读(1653)  评论(0编辑  收藏  举报
夫人不言,言必有中。这是高级臣僚的一种可贵品质,言辞精炼,直抵要害。