因此,我的数据库表中"country“行中有一个名为”country list“的230个国家/地区的列表。除了" country“行之外,我还有" code”行,其中包含该国家的国家代码。
国家是英文的,因为我还需要其他3种语言的国家名称,我也复制了其他3种语言的表格。我还编写了PHP代码以根据语言选择正确的表。
我有其他3种语言的国家名称的名单准备好了,他们有相同的顺序。
但是..。这使得我有230个国家需要替换3种语言,这对于我已经知道应该比基本的复制粘贴简单得多的东西来说是浪费了大量的时间。尽管我甚至对如何或者是否可以做到这一点都没有丝毫的了解。
我想知道是否有一种方法可以保留表中的"code“行,并用查询/命令替换"country”行中的所有国家?
谢谢,任何帮助都非常感谢。
发布于 2013-04-25 09:20:38
由于之前代码的性质,没有一个答案是实用的,所以我不得不使用Dreamweaver copy and replace手动重做所有事情。花了一个小时,但做得很好。
发布于 2013-04-18 09:17:49
INSERT INTO countries_fr (code) SELECT countries_en.code FROM countries_en假设您有表countries_fr和countries_en,并且这两个表都有code列。这将把countries_en表中的所有代码插入到countries_fr表的code中。
发布于 2013-04-18 09:28:50
所以它是标准化的,你必须为表中的其他3个名称添加列,所以(用所需的语言替换):
alter table countries add french varchar(45),spanish varchar(45),russian varchar(45);因为代码是完全相同的,所以这一次你可以像使用键字段一样使用它。
update countries c set c.french=(select country from french where french.code = countries.code),
c.spanish=(select country from spanish where spanish.code = countries.code),
c.russian=(select country from russian where russian.code = countries.code);另一方面,...
如果您要简单地替换国家/地区名称,则必须维护4组代码。
update countries set country=(select country from language2 where language2.code=countries.code);https://stackoverflow.com/questions/16072807
复制相似问题