PHP MySql Web Hosting

PHP and MySQL Web Development

,ch04.13730 Page 169 Wednesday, November 29, 2000 4:43

Filed under: SQL in a Nutshell — webmaster @ 10:41 pm

,ch04.13730 Page 170 Wednesday, November 29, 2000 4:43 PM SELECT PATINDEX( ‘%fg’, ‘abcdefg’ ) GO -> 6 String Functions Basic string functions offer a number of capabilities and return a string value as a result set. Some string functions are dyadic, indicating that they operate on two strings at once. SQL99 supports the string functions listed in Table 4-6. Table 4-6: SQL String Functions Function CONCATENATE (expression || expression) CONVERT LOWER SUBSTRING TRANSLATE TRIM UPPER Usage Appends two or more literal expressions, column values, or variables together into one string. Converts a string to a different representation within the same character set. Converts a string to all lowercase characters. Extracts a portion of a string. Converts a string from one character set to another. Removes leading characters, trailing characters, or both from a character string. Converts a string to all uppercase characters. CONCATENATE SQL99 defines a concatenation operator ( || ), which joins two distinct strings into one string value. The CONCATENATE function appends two or more strings together, producing a single output string. PostgreSQL and Oracle support the double-pipe concatenation operator. Microsoft SQL Server uses the plus sign (+) concatenation operator. MySQL supports a similar function, CONCAT( ). Refer to the Concatenation Operators section Chapter 3, SQL Statements Command Reference, for more information on concatenation within Oracle, PostgreSQL, and Microsoft SQL Server. SQL99 Syntax CONCATENATE(’string1′ || ’string2′) MySQL Syntax CONCAT(str1, str2, [,…n]) If any of the concatenation values are null, the entire returned string is null. Also, if a numeric value is concatenated, it is implicitly converted to a character string: SELECT CONCAT(’My ‘, ‘bologna ‘, ‘has ‘, ‘a ‘, ‘first ‘, ‘name…’); -> ‘My bologna has a first name…’ SELECT CONCAT(’My ‘, NULL, ‘has ‘, ‘first ‘, ‘name…’); -> NULL 170 Chapter 4 SQL Functions

Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost PHP Web Hosting services

No Comments

No comments yet.

RSS feed for comments on this post. TrackBack URI

Sorry, the comment form is closed at this time.

Powered by PHP MySQL Web Hosting