LEADING is one of three trim specifiers (LEADING, TRAILING, BOTH) defined by the SQL standard. When used inside the TRIM function it tells the database to strip the specified trim characters only from the beginning (left side) of the input string. If no trim character list is supplied, spaces are assumed. LEADING never alters characters that appear after the first non-match; trimming stops as soon as a character not in the trim list is encountered. LEADING is not a stand-alone statement; it is valid only as part of TRIM, and its behavior can differ slightly between dialects that also support the shorter LTRIM(string) form.
trim_character_list
(string) - Optional list of characters to remove. Defaults to space if omitted.source_string
(string) - The value to be trimmed.TRIM, TRAILING, BOTH, LTRIM, RTRIM, SUBSTRING
SQL:1999
Most mainstream engines including PostgreSQL, MySQL, MariaDB, Oracle, SQL Server 2017+, SQLite, Snowflake, BigQuery, and Redshift implement LEADING inside TRIM.
Use the default behavior: `TRIM(LEADING FROM my_col)` or simply `TRIM(LEADING my_col)` in MySQL. This strips spaces from the start of `my_col`.
Yes. Provide a list of characters: `TRIM(LEADING 'xyz' FROM 'xxygalaxy')` returns `galaxy`.
LEADING stops trimming at the first character not in the trim list. It never deletes internal characters; use REPLACE or REGEXP_REPLACE for that.