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
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:
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 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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.