



分析:分析发现,该表中除开bianhao及 qrcode 字段不一样外,其他字段都一样,bianhao字段内容对应qrcode 后面内容,如图

域名用想起可将这些内容放在C#数组中,然后在遍历数组生成具体sql语句,在将语句导入即可.最终问题解决。
代码如下
生成的sql如下:using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace ConsoleApp3
{
class Program
{
static void Main(string[] args)
{
string C;
long[] bianhao = new long[] { 2123123132231,5456465456,545645646,456456465 }; //若数据较大,可直接从txt文件中读取
for (long i = 0; i < bianhao.Length; i++)
{
C = "INSERT INTO `az522`.`tgs_code` (`id`, `bianhao`, `riqi`, `product`, `zd1`, `zd2`, `tupian`, `jianjie`, `qrcode`, `hits`, `query_time`) VALUES('', '" + bianhao[i] + "', '2020-12-31', 'AZ第一批', '--', '--', 'http://BLOG.TAG.GG//upload/nopic.jpg', '', 'http://BLOG.TAG.GG//qrcode.php?bianhao=" + bianhao[i]+ "', '0', NULL);"+"\n";
using (StreamWriter sw = new StreamWriter(@"d:\sql.txt", true)) //将sql语句生成到sql.txt中
{
sw.WriteLine(C); //追加写入。
}
}
}
}
}

在navicat中导入成功:




文章评论 本文章有个评论