Skip to content

MySQL string functions

DataBase

SUBSTR() function

MySQL SUBSTR() returns the specified number of characters from a particular position of a given string. SUBSTR() is a synonym for SUBSTRING().

Syntax:

SUBSTR(str, pos, len)

Arguments

Name Description
str A string from which a substring is to be returned.
pos An integer indicating a string position within the string str.
len

An integer indicating a number of characters to be returned.

LEFT() function

MySQL LEFT() returns a specified number of characters from the left of the string. Both the number and the string are supplied as arguments of the function.

Syntax:

LEFT (string, length)

Arguments

Name Description
string The string from which a number of characters from the left are to be returned.
length An integer which indicates the number of characters to be returned starting from the left of the string in the first argument.

RIGHT() function

MySQL RIGHT() extracts a specified number of characters from the right side of a string.

Syntax:

RIGHT(str, len)

Arguments

Name Description
str A string from whose right side a number of characters are to be extracted.
len An integer indicating the number of characters to be extracted from str.

 

Trackbacks

No Trackbacks

Comments

Display comments as Linear | Threaded

No comments

Add Comment

Enclosing asterisks marks text as bold (*word*), underscore are made via _word_.
Standard emoticons like :-) and ;-) are converted to images.
E-Mail addresses will not be displayed and will only be used for E-Mail notifications.
To leave a comment you must approve it via e-mail, which will be sent to your address after submission.

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA

Form options

Submitted comments will be subject to moderation before being displayed.