Page 191 - SQL
P. 191

SUBSTR ( string-expression, length(string-expression)-integer+1, integer)


         SELECT SUBSTR('Hello',1,2)  --return He
         SELECT SUBSTR('Hello',LENGTH('Hello')-2+1,2) --return lo


        REVERSE


        Syntax is: REVERSE ( string-expression )


         SELECT REVERSE('Hello') --returns olleH


        REPLICATE



        The REPLICATE function concatenates a string with itself a specified number of times.

        Syntax is: REPLICATE ( string-expression , integer )


         SELECT REPLICATE ('Hello',4) --returns 'HelloHelloHelloHello'


        REGEXP


        MySQL3.19


        Checks if a string matches a regular expression (defined by another string).


         SELECT 'bedded' REGEXP '[a-f]' -- returns True

         SELECT 'beam' REGEXP '[a-f]' -- returns False


        Replace function in sql Select and Update query


        The Replace function in SQL is used to update the content of a string. The function call is
        REPLACE( ) for MySQL, Oracle, and SQL Server.

        The syntax of the Replace function is:


         REPLACE (str, find, repl)


        The following example replaces occurrences of South with Southern in Employees table:



          FirstName     Address

          James         South New York


          John          South Boston

          Michael       South San Diego




        https://riptutorial.com/                                                                             173
   186   187   188   189   190   191   192   193   194   195   196