🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
![](https://img.kancloud.cn/41/e0/41e066af9a6c25a24868d9667253ec98_1241x333.jpg) ***** ## 创建 "商品分类" 表 ~~~ create table goods_cates( id int unsigned primary key auto_increment not null, name varchar(40) not null ); ~~~ * 查询goods表中商品的种类 ~~~ select cate_name from goods group by cate_name; ~~~ * 将分组结果写入到goods\_cates数据表 ~~~ insert into goods_cates (name) select cate_name from goods group by cate_name; ~~~ ### 同步表数据 * 通过goods\_cates数据表来更新goods表 ~~~ update goods as g inner join goods_cates as c on g.cate_name=c.name set g.cate_name=c.id; ~~~