Vamos dizer que tenho algo assim
uid tag
1 HeLLo
2 heLLO
3 HELLO
4 hello
Como posso atualizar todos os valores na coluna "tag" para:
uid tag
1 hello
2 hello
3 hello
4 hello
usando MySQL?
Vamos dizer que tenho algo assim
uid tag
1 HeLLo
2 heLLO
3 HELLO
4 hello
Como posso atualizar todos os valores na coluna "tag" para:
uid tag
1 hello
2 hello
3 hello
4 hello
usando MySQL?
Respostas:
Consulte http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_lower
UPDATE table_name SET tag = LOWER(tag)
UPDATE table_name SET tag = BINARY LOWER(tag)para correspondência sem distinção entre maiúsculas e minúsculas.
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
update table set tag = LOWER(tag)
Versão para correspondência sem distinção entre maiúsculas e minúsculas e incluindo uma cláusula "WHERE" se você não quiser atualizar a coluna inteira:
UPDATE table
SET tag = LOWER(tag)
WHERE LOWER(tag) != tag
COLLATE Latin1_General_CS_AS
A linha COLLATE fará com que funcione se o seu banco de dados usar correspondência que não diferencia maiúsculas de minúsculas, como o meu faz.
Experimente isto:
update `table` set `column_name` = LOWER(column_name without quotation)