简体   繁体   English

从一列中选择,然后插入附加了一些字符串的另一列中?

[英]Select from one column and insert into another column with some string appended?

I have a table countries with three columns country_name, country_code, country_flag . 我有一个表countries其中有三列country_name, country_code, country_flag

The table has 250 rows but the country_flag column is all null at the moment because I have created it now. 该表有250行,但是country_flag列目前全部为空,因为我现在已经创建了它。

The purpose of this column is to contain a path to the flag file (Image) of that country like Images\\Flags\\UK.gif (each flag file is named as the country code). 该列的目的是包含指向该国家的标记文件(Image)的路径,例如Images\\Flags\\UK.gif (每个标记文件都称为国家代码)。 Now I want to write a query that should pick country code from the country_code column and append the Images\\Flags\\ string at the start and .gif at the end, something like this 现在,我想编写一个查询,该查询应从country_code列中选择国家/地区代码,并在开头添加Images\\Flags\\字符串,并在结尾添加.gif ,如下所示

'Images\Flags\' + country_code + '.gif' 

and then update the country_flag column with this value. 然后使用此值更新country_flag列。

If this is possible then it will update the table with less effort and I'll get all image paths in the country_flag column. 如果可以的话,它将以较少的工作量更新表,并且我将在country_flag列中获取所有图像路径。

尝试这个

Update countries set country_flag = 'Images\Flags\' + country_code + '.gif'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM