The LCASE() function in MySQL is used to convert a given string to lowercase. It is a string function that takes a string argument and returns the string with all characters in lowercase.
Syntax:
LCASE(string)
- string: The string expression you want to convert to lowercase.
Example Usage:
-
Basic Example:
SELECT LCASE('Hello World');Result:
hello world -
Using with a Column: If you have a table with a column of strings and want to convert all the values in that column to lowercase, you can use
LCASE()in aSELECTquery.SELECT LCASE(name) FROM employees;This will return all the values in the
namecolumn converted to lowercase. -
With WHERE Clause: You can use
LCASE()in theWHEREclause to perform case-insensitive searches.SELECT * FROM employees WHERE LCASE(name) = 'john doe';This ensures the search is case-insensitive, matching 'John Doe', 'john doe', etc.
Notes:
LCASE()is an alias forLOWER()in MySQL, so both functions work the same way.- It only affects alphabetic characters and does not modify numbers or special characters.
No comments:
Post a Comment