Use of the left () and charindex () functions in SQL

Source: Internet
Author: User
Tags how to use sql

SQL has various functions. The following describes how to use the left () function and charindex () function in SQL, it is helpful for you to learn how to use SQL functions.

View Code

1. left ()
2 LEFT (<character_expression>, <integer_expression>)
3. The character character_expression starts from integer_expression on the left.
4
5 2. charindex ()
6. Return the starting position of a specified substring in the string.
7 CHARINDEX (<'substring _ expression' >,< expression>)
8. substring _ expression is the character expression to be searched. expression can be a string or a column name expression. If no substring is found, the return value is 0.
9 This function cannot be used for TEXT and IMAGE data types.
10
11 as shown in the following table test
12
13. Implement the following data effects:
14
15 then the left () and charindex () functions are required.
16
17 select left (t_cont, CHARINDEX (':', t_cont)-1) as content from test where t_cont like '%: %' left () function and charindex () in SQL () function usage

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.