SQL查询:复制Store_ID = 1的所有行

时间:2015-07-07 16:35:53

标签: mysql sql magento review

我有一个包含两列的表figure; %// Plot line plot3([a(1) b(1)], [a(2) b(2)], [a(3) b(3)]); hold on; %// Plot point of interest in red plot3(c(1), c(2), c(3), 'r.'); %// Plot intersection point in green plot3(Xinter(1), Xinter(2), Xinter(3), 'g.'); %// Plot line from intersection point to point of interest in black plot3([c(1) Xinter(1)], [c(2) Xinter(2)], [c(3) Xinter(3)], 'k'); %// Turn on a grid grid; review_storereview_id 如果我不得不用2替换1,我会这样做:

store_id

如何将store_ID = 1的每一行复制/复制到Store_ID = 2?

3 个答案:

答案 0 :(得分:2)

我认为你的意思是在同一个表中创建新记录。使用INSERT SELECT

INSERT INTO review_store
SELECT review_id, '2' as Store_id
FROM review_store
WHERE Store_id = '1'

答案 1 :(得分:2)

INSERT INTO review_store (review_id, store_id)
SELECT review_id, 2
FROM review_store 
WHERE store_id = 1

答案 2 :(得分:0)

INSERT INTO `review_store` SELECT 2, review_id FROM `review_store` WHERE store_id = 1

请注意,如果您有一个id列,则应为其添加一个空白字段,所以

INSERT INTO `review_store` SELECT '', 2, review_id FROM `review_store` WHERE store_id = 1

检查字段的顺序。如果review_id出现在store_id之前,则您需要重新排序选择。