Home > Database > Mysql Tutorial > Which MySQL function returns a specified number of strings as output?

Which MySQL function returns a specified number of strings as output?

WBOY
Release: 2023-08-25 11:01:04
forward
1266 people have browsed it

哪个 MySQL 函数返回指定数量的字符串作为输出?

MySQL returns the specified number of characters in a string with the help of the LEFT() and RIGHT() functions.

MySQL LEFT() function will return the specified number of characters from the left side of the string.

Syntax

LEFT(str, length)
Copy after login

Here str is a string of multiple characters to be returned, and the length is an integer value specifying the number of characters to be returned.

Example

mysql> Select LEFT('My Name is Ram', 7);
+---------------------------+
| LEFT('My Name is Ram', 7) |
+---------------------------+
| My Name                   |
+---------------------------+
1 row in set (0.00 sec)
Copy after login

The MySQL RIGHT() function will return the specified number of characters from the right side of a string.

Syntax

RIGHT(str, length)
Copy after login

Here str is a string of multiple characters to be returned, and the length is an integer value specifying the number of characters to be returned.

Example

mysql> Select RIGHT('My name is Ram',6);
+---------------------------+
| RIGHT('My name is Ram',6) |
+---------------------------+
| is Ram                    |
+---------------------------+
1 row in set (0.00 sec)
Copy after login

The above is the detailed content of Which MySQL function returns a specified number of strings as output?. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template