[英]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.