我有以下两个sql语句
LOAD DATA LOCAL INFILE '~/data/geo_blocks.csv' INTO TABLE geo_blocks FIELDS ENCLOSED BY '\"'TERMINATED BY ',' LINES TERMINATED BY '\n' (ip_start, ip_end, location_id);
&安培;
update geo_blocks set index_geo = (ip_end - mod(ip_end, 65536));
是否有办法将LOAD DATA语句组合在一起同时执行计算?
答案 0 :(得分:4)
您应该在LOAD DATA INFILE命令 -
中尝试SET子句LOAD DATA LOCAL INFILE '~/data/geo_blocks.csv'
INTO TABLE geo_blocks
FIELDS ENCLOSED BY '\"'TERMINATED BY ','
LINES TERMINATED BY '\n'
(@ip_start, @ip_end, location_id)
SET index_geo = @ip_end - MOD(@ip_end, 65536);