SQL commonly used functions and advanced query

Section describes the function

--substring (field names, n, m)   dividing a field string block from the n m-bit characters behind the characters
select SUBSTRING (NAME, 1,3),     NAME from Student where ID = 1

*************************************************************************************************************************************

--STUFF (str1, n, m, str2)     a first sub-string deleted from the n m-bit bit string is inserted into the second
select STUFF (NAME, 2,1, ' qqqqq'), Name from Student where ID = 1    

*************************************************************************************************************************************

--left function     left (field, N number) from the left N characters
select left (NAME, 4),  NAME from Student where ID = 1

*************************************************************************************************************************************

--right function right (field, N number) of N characters starting from the right
select right (NAME, 4), NAME from Student where ID = 1

*************************************************************************************************************************************

--REPLICATE function Repeat to specify the number of times a character expression

select REPLICATE(NAME,3),NAME from Student where ID=1

*************************************************************************************************************************************

- ltrim rtrim function and  delete the spaces left and right spaces  TRIM to the middle in order to use the space 2017SQl

select LTRIM(NAME),RTRIM(NAME),TRIM(NAME),NAME from Student where ID=1

 

*************************************************************************************************************************************

To be continued!

 

Guess you like

Origin www.cnblogs.com/wangyihui/p/12553222.html