Ltrim Function In Sql in SQL
? LTRIM Function in SQL
The LTRIM function removes leading spaces (spaces on the left side) from a string.
? Syntax:
LTRIM(string)string: The text you want to trim leading spaces from.
? Example:
SELECT LTRIM(' Hello World') AS trimmed;Result:
| trimmed |
|---|
| Hello World |
? Notes:
It does not remove trailing spaces (use
RTRIMfor that).To remove both leading and trailing spaces, use:
TRIM()(in most modern databases)
Supported in:
? MySQL
? SQL Server
? PostgreSQL
? Oracle
? Combined Example:
SELECT LTRIM(' Text') AS left_trim, RTRIM('Text ') AS right_trim, TRIM(' Text ') AS full_trim;Let me know if you want string cleanup examples in a real table!