//这是从自定义sql中获取的var sql=[ "insert into 产品lr(产品id,产品名称) values('",
["94"], //数组的长度不确定
"','",
["DDDfffDDD","DDD盐DDD","DDD海鲜粉DDD","DDD胡椒粉DDD","DDD333DDD"], 数组的长度不确定 "','", "", "''\n\n)"
]//最后要得到:(循环插入使用)[
"insert into 产品lr(产品id,产品名称) values('94','DDDfffDDD')",
"insert into 产品lr(产品id,产品名称) values('94','DDD盐DDD')",
"insert into 产品lr(产品id,产品名称) values('94','DDD海鲜粉DDD') ",
"insert into 产品lr(产品id,产品名称) values('94','DDD胡椒粉DDD')",
"insert into 产品lr(产品id,产品名称) values('94','DDD333DDD')" ]这个该怎么实现?
2 回答
冉冉说
TA贡献1877条经验 获得超1个赞
insert into 产品lr(产品id,产品名称,供应商名称,型号) values('94',['DDDfffDDD','DDD盐DDD','DDD海鲜粉DDD','DDD胡椒粉DDD','DDD333DDD'],['fff','盐','海鲜粉','胡椒粉','333'],'DDDfffDDD,DDD盐DDD,DDD海鲜粉DDD,DDD胡椒粉DDD,DDD333DDD')
存成这样,然后找到数组,双层for循环即可。
桃花长相依
TA贡献1860条经验 获得超8个赞
let res1 = [] sql[1].forEach(value => { sql[3].forEach(value1 => { let item1 = `${sql[0]}${value}','${value1}'),`; res1.push(item1) }); })console.log(res1)
- 2 回答
- 0 关注
- 648 浏览
添加回答
举报
0/150
提交
取消