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