SQL 将值更改为大写或小写
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/341338/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
SQL changing a value to upper or lower case
提问by Joshua Hudson
How do you make a field in a sql select statement all upper or lower case?
如何使sql select语句中的字段全部大写或小写?
Example:
例子:
select firstname from Person
从人中选择名字
How do I make firstname always return upper case and likewise always return lower case?
如何让名字总是返回大写,同样总是返回小写?
回答by Jared
SELECT UPPER(firstname) FROM Person
SELECT LOWER(firstname) FROM Person
回答by Stephen Wrighton
LCASE or UCASE respectively.
分别是 LCASE 或 UCASE。
Example:
例子:
SELECT UCASE(MyColumn) AS Upper, LCASE(MyColumn) AS Lower
FROM MyTable
回答by Cirieno
SQL SERVER 2005:
SQL 服务器 2005:
print upper('hello');
print lower('HELLO');
回答by Muhammad Awais
You can use LOWER function
and UPPER function
. Like
您可以使用LOWER function
和UPPER function
。喜欢
SELECT LOWER('THIS IS TEST STRING')
Result:
结果:
this is test string
And
和
SELECT UPPER('this is test string')
result:
结果:
THIS IS TEST STRING
回答by Xyed Xain Haider
You can do:
你可以做:
SELECT lower(FIRST NAME) ABC
FROM PERSON
NOTE: ABC
is used if you want to change the name of the column
注意:ABC
如果要更改列的名称,则使用