【发布时间】:2014-08-01 13:23:25
【问题描述】:
我正在使用insert into table2 select from table1 声明。
table2 的字段比table1 多。除了选择结果中的值之外,我如何使用其他值填充额外的字段。
table1 有col1, col2, col3 table2 has col1, col2, col3, col4, col5, col6
table2 中的 col4 和 col5 将使用 col2 和 col3 中的修改值。
示例:
tabl1.col2 的值为 tag 6512,tabl1.col3 的值为 bin location
table2 中的col4 将使用 table1.col3 中的部分值 bin 和 table1.col2 中的“6512”
所以table2.col4 将是bin 6512
sql:
insert into table2(col1, col2, col3, col4, col5) select * from table1 (and add values for col4 and col5)
感谢任何帮助。
【问题讨论】:
-
似乎(至少在我看来!)在运行插入之前操作 select 语句的结果是最简单的
标签: php sql mysqli-multi-query