In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains "how to intercept the first few bits of a string by mysql". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "how mysql intercepts the first few bits of a string".
Mysql intercepts the first few bits of a string: 1, using the LEFT () function, syntax "left (intercepted string, intercepted length)"; 2, using SUBSTRING () function, syntax "substring (intercepted string, 1, intercepted length)".
The operating environment of this tutorial: windows7 system, mysql8 version, Dell G3 computer.
Mysql's method to intercept the first few bits of a string:
1. Use the LEFT () function
The LEFT () function can intercept strings from the left
Usage: left (str, length), that is: left (truncated string, intercepted length)
[example] use the LEFT function to return the left character in the string
Mysql > SELECT LEFT ('MySQL',2); +-+ | LEFT (' MySQL',2) | +-+ | My | +-+ 1 row in set (0.04 sec)
As you can see from the running result, a substring of length 2 starting to the left of the string "MySQL" is returned, and the result is "My".
2. Use the SUBSTRING () function
The SUBSTRING () function intercepts a string of a specific length
Usage:
Substring (str, pos, length), namely: substring (intercepted string, from which bit to intercept, intercept length)
When the second argument of the SUBSTRING () function, pos, is 1, it intercepts a string of a specific length from the beginning.
It is also possible to use a negative value for pos. If so, the position of the substring begins with the pos character at the end of the string, that is, the penultimate pos character, not the beginning of the string.
[example] use the SUBSTRING function to get the substring at the specified location
Mysql > SELECT SUBSTRING ('computer',1,3) AS col1,-> SUBSTRING (' computer',3,4) AS col2,-> SUBSTRING ('computer',-3) AS col3,-> SUBSTRING (' computer',-5,3) AS col4 +-+ | col1 | col2 | col3 | col4 | +-+ | com | mput | ter | put | +-+ 1 row in set (0.00 sec) so far I believe you have a deeper understanding of "mysql how to intercept the first few bits of a string". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.