MySQL RPAD Function

Example

Right-pad the string with “ABC”, to a total length of 20:

SELECT RPAD("SQL Tutorial", 20, "ABC");

Definition and Usage

The RPAD() function right-pads a string with another string, to a certain length.

Note: Also look at the LPAD() function. Continue reading MySQL RPAD Function

MySQL RIGHT Function

Example

Extract 4 characters from a string (starting from right):

SELECT RIGHT("SQL Tutorial is cool", 4) AS ExtractString;

Definition and Usage

The RIGHT() function extracts a number of characters from a string (starting from right).

Tip: Also look at the LEFT() function. Continue reading MySQL RIGHT Function