2
I got the following SQL:
UPDATE tabela SET peso = peso "KG"
I need to add to the weight field, the tag KG, But if I do it the way I put it, it doesn’t work. How could I do it?
2
I got the following SQL:
UPDATE tabela SET peso = peso "KG"
I need to add to the weight field, the tag KG, But if I do it the way I put it, it doesn’t work. How could I do it?
5
Use simple quotes to concatenate the text 'KG'
SQL SERVER:
Beyond the function CONCAT() you can use the +
to concatenate the current value of the column with KG:
UPDATE tabela SET peso = peso + 'KG'
Sqlite:
Use the ||
for concatenate, the CONCAT
here doesn’t work.
UPDATE Tabela Set Coluna = Coluna || 'KG'
Mysql:
Utilize CONCAT():
UPDATE tabela SET peso = CONCAT(peso, 'KG');
Note: It is also possible to do with ||
as in the Sqlite but for this you must configure the Mysql to accept, setando sql_mode
for PIPES_AS_CONCAT
.
Postgresql:
Beyond the function CONCAT() you can use the ||
to concatenate.
UPDATE Tabela Set Coluna = Coluna || 'KG'
Oracle:
Beyond the function CONCAT() you can use the ||
to concatenate.
UPDATE Tabela Set Coluna = Coluna || 'KG'
All commands above have been tested on Sqlfiddle.
Has DBMS may not understand string "sums"
Updated response
What an answer! It looks great
3
You have to concatenate what is stored most to tag
KG:
UPDATE tabela SET peso = CONCAT(peso, " KG");
Killed the riddle! Top top!
Browser other questions tagged sql
You are not signed in. Login or sign up in order to post.
Depends on the DBMS, in Sqlserver accepts the + to concatenate the strings, already in Sqlite I think it is with |
– Jefferson Quesado
@Andrébaill Which is the database manager?
– José Diz