1、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 條件 注意:前后兩個表中的字段名一致,可以使用該方法
2、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 條件