【发布时间】:2014-11-13 21:40:03
【问题描述】:
所以根据我的需要,我必须将数据从 table1 复制到 table2,为此我使用 INSERT SELECT QUERY。这里是:
$sql = "INSERT INTO `attribute_details_versions`(`attribute_details_id`,`attribute_name`,`attribute_text`,`attribute_value`,`created_at`,`updated_at`) SELECT `attribute_details_id`,`attribute_name`,`attribute_text`,`attribute_value`,`created_at`,`updated_at`FROM `attribute_details`";
在上述查询中,来自attribute_details 的数据正在复制到attribute_details_versions 表中,并且工作正常。
但表 version 中还有 1 列 version,我需要在此列中提交自定义值,如任何整数值(1 或 2 等)。 这个version column is not exist inattribute_details` 表那么我如何使用 SELECT INSERT QUERY 插入这个自定义值?
任何帮助将不胜感激。
【问题讨论】:
-
所有行的值都相同吗?
-
@VMai 是的,所有行都是一样的。
标签: php mysql sql select insert