开发者

Copy rows and insert in source table

开发者 https://www.devze.com 2023-02-14 03:05 出处:网络
In MySQL I have a table design like this: Language|Key|Text Language and Key are primary keys. A content example could be:

In MySQL I have a table design like this:

Language|Key|Text 

Language and Key are primary keys. A content example could be:

("ENU","P_Home_H2","Welcome to my page"),
("ENU","P_Home_P1","Hello world!")

Now I want to copy all rows with Language="开发者_开发技巧ENU" to Language="ESP", ie select all rows where Language = "ENU" and insert into same table, with same Key and Text but Language="ESP". The result would be:

("ESP","P_Home_H2","Welcome to my page"),
("ESP","P_Home_P1","Hello world!")

How do I do this?


Insert into MyTable
Select 'ESP' as Language, Key, Text
From MyTable 
Where Language = 'ENU'


INSERT INTO existingTable
Select 'ESP' as Language, [Key], Text
FROM newTable
WHERE Language = 'ENU'
0

精彩评论

暂无评论...
验证码 换一张
取 消