sql 语句 将一个表中的数据插入到另外一个表中

一、insert INTO ns_goods_category (shop_id,category_name,short_name,level) select shop_id,"其余","其余",1 from ns_shop where shop_id >0;
"其余","其余",1
表明插入的表中有的字段而查询的表中没有该字段insert into 表名 (字段名) select 字段名 from 表名 where 条件     注意:先后两个表中的字段名一致,能够使用该方法 二、update ns_goods g,ns_goods_category c set g.category_id=c.category_id,g.category_id_1=c.category_id where g.shop_id=c.shop_id and g.category_id_1 > 0 and g.shop_id >0;含义:表示将A表中的数据根据条件修改成B表中的数据update table1,table2 set table1.字段名=table2.字段名 where table1.(与table2表有关联的字段)=table2.(与table1有关联的字段) and 条件
相关文章
相关标签/搜索