我想做这样的事情
Insert into abc(col1, col2, col3) select col1, 1, col3 from xyz where somecondition
Insert into abc(col1, col2, col3) select col1, 2, col3 from xyz where somecondition
Insert into abc(col1, col2, col3) select col1, 3, col3 from xyz where somecondition
Insert into abc(col1, col2, col3) select col1, 4, col3 from xyz where somecondition
...
所以只有第二列的值在变化,其他的都是一样的。
有没有更好或更紧凑的方法来完成上述操作?可能是一个查询!
我正在使用 MySql
编辑:
我在存储过程中使用它。