In this tutorial we will have a look at the Trim function of MySQL. MySQL has a very strong library we must use it, usually we format input our data using some dynamic languages like PHP, but what if there is a scenario we have to use MySQL database for it.
let the code talk...
lets understand it with examples.
let the code talk...
MySQL Trim Method Signature
// First Type String TRIM([{BOTH | LEADING | TRAILING} [STRING_TO_BE_REMOVED] FROM] str) // Second Type String TRIM([STRING_TO_BE_REMOVED FROM] str)Returns the string string with all STRING_TO_BE_REMOVED prefixes or suffixes removed. If none of the specifiers BOTH, LEADING, or TRAILING is given, BOTH is assumed. STRING_TO_BE_REMOVED is optional and, if not specified, spaces are removed.
lets understand it with examples.
Example
SELECT TRIM(' Tutorial ') AS FormatedString;Outputs: Tutorial
SELECT TRIM(LEADING 'jinni' FROM 'jinniTutorialjinni') AS FormatedString;Outputs: Tutorialjinni
SELECT TRIM(BOTH 'jinni' FROM 'jinniTutorialjinni') AS FormatedString;Outputs: Tutorial
SELECT TRIM(TRAILING 'jinni' FROM 'jinniTutorialjinni') AS FormatedString;Outputs: jinniTutorial
0 comments:
Post a Comment