在MySQL中,我有一个像这样的表格设计:
Language|Key|Text
语言和密钥是主键。内容示例可能是:
("ENU","P_Home_H2","Welcome to my page"),
("ENU","P_Home_P1","Hello world!")
现在我想用Language =“ENU”将所有行复制到Language =“ESP”,即选择Language =“ENU”的所有行并插入到同一个表中,使用相同的键和文本但语言=“ESP” 。结果将是:
("ESP","P_Home_H2","Welcome to my page"),
("ESP","P_Home_P1","Hello world!")
我该怎么做?
答案 0 :(得分:2)
Insert into MyTable
Select 'ESP' as Language, Key, Text
From MyTable
Where Language = 'ENU'
答案 1 :(得分:0)
INSERT INTO existingTable
Select 'ESP' as Language, [Key], Text
FROM newTable
WHERE Language = 'ENU'