mysql查询后插入数据

方法一:insert into pur_purchase_item_config select '',id,item_code,7,15,1.5,'SYSTEM',now(),
'SYSTEM',now() from hic_item where status in (-2,1,3,5,6);
缺点:会锁表,

方法二:
SELECT * INTO OUTFILE '/tmp/20130520itemtmp.txt' FIELDS TERMINATED BY ',' ENCLOSED BY '"'
FROM (SELECT id AS item_id,item_code,7 AS safe_stock_day,15 AS single_purchase_day,1.5 AS puchase_time_factor,'SYSTEM' AS creator_name,NOW() AS gmt_create,
'SYSTEM' AS modifier_name,NOW() AS gmt_modified FROM hic_item WHERE STATUS IN (-2,1,3,5,6)) t;

LOAD DATA INFILE '/tmp/20130520itemtmp.txt' IGNORE INTO TABLE pur_purchase_item_config FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n' 
(item_id,item_code,safe_stock_day,single_purchase_day,puchase_time_factor,creator_name,gmt_create,modifier_name,gmt_modified);
缺点:语句较复杂
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值