[英]change substring to upper case
I have this query to select part of substring by >. 我有此查询通过>选择子字符串的一部分。
SELECT SUBSTRING_INDEX(translation, '>', 1) FROM categorias
What I want is update the substring to the upper case. 我想要的是将子字符串更新为大写。
However this query has a sintax error 但是此查询有一个sintax错误
UPDATE A.translation
SET A.translation = UPPER(SELECT SUBSTRING_INDEX(A.translation, '>', 1))
FROM categorias as A
Any help? 有什么帮助吗?
data example: 数据示例:
Raw Materials & Chemicals > Rubber & Elastomers
that should be updated to 应该更新为
RAW MATERIALS & CHEMICALS > Rubber & Elastomers
I believe you can remove the inner SELECT
and you can alter your UPDATE
syntax slightly to the following: 我相信您可以删除内部的SELECT
并且可以将UPDATE
语法略微更改为以下内容:
UPDATE categorias
SET translation = UPPER(SUBSTRING_INDEX(translation, '>', 1))
Based on your comments I think you want the following: 根据您的评论,我认为您需要:
UPDATE categorias
SET translation
= CONCAT(
UPPER(SUBSTRING_INDEX(translation, '>', 1)),
SUBSTRING(translation, INSTR(translation, '>')));
UPDATE
references the table, not the column you are updating, eg: UPDATE
引用表,而不是要更新的列,例如:
UPDATE categorias
SET translation = UPPER(SUBSTRING_INDEX(translation, '>', 1))
Note also, you don't need to use SELECT
with string functions, they return their results without it. 还要注意,您不需要将SELECT
与字符串函数一起使用,它们会在不使用SELECT
情况下返回结果。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.