sqloracle-databasesubstring

Oracle SQL. how to trim a leading substring


I wish to remove a leading substring from a string. I tried to use LTRIM function, but it returned a bad result. In detail

SELECT LTRIM(' AND DAT_MOD = ...', ' AND ') FROM DUAL;

returned

T_MOD = ...

instead of the expected

DAT_MOD = ...

I suppose that I should to convert the ' AND ' string to be trimmed as an object, rather than a set of characters. How can I get it?


Solution

  • SELECT SUBSTR(' AND DAT_MOD = ...',length(' AND ')) "Substring"
         FROM DUAL;