PHP MySql Web Hosting

PHP and MySQL Web Development

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

Filed under: SQL in a Nutshell — webmaster @ 2:30 pm

,ch04.13730 Page 168 Wednesday, November 29, 2000 4:43 PM BIT_LENGTH, CHAR_LENGTH, and OCTET_LENGTH The closest any of the vendors get to the BIT_LENGTH function is Oracle. Oracle supports the LENGTHB function, which returns an integer value representing the number of bytes in an expression. MySQL and PostgreSQL support CHAR_LENGTH and the SQL99 synonym CHARACTER_LENGTH( ). PostgreSQL also supports EXTRACT( ), OCTET_LENGTH( ), and POSITION( ) as per the SQL99 standard. The other two vendors each have a similar function that provides identical functionality. SQL Server provides the LEN function and Oracle provides the LENGTH function. MySQL and PostgreSQL also fully support the OCTET_LENGTH function. Example The following example determines the length of a string and a value retrieved from a column: /* On MySQL and PostgreSQL */ SELECT CHAR_LENGTH(’hello’); SELECT OCTET_LENGTH(book_title) FROM titles; /* On Microsoft SQL Server */ SELECT DATALENGTH(title) FROM titles WHERE type = ‘popular_comp’ GO /* On Oracle */ SELECT LENGTH(’HORATIO’) “Length of characters” FROM dual; EXTRACT The EXTRACT function is not supported by the database vendors, except for PostgreSQL and MySQL. Each vendor supports a separate command to accomplish the same functionality. Oracle uses the TO_CHAR function to extract a portion of a date into a character string. SQL Server uses the CONVERT function to extract a portion of a date. MySQL implementation is extended somewhat beyond the SQL99 standard. The SQL99 standard does not have a provision for returning multiple fields in the same call to EXTRACT( ) (e.g., DAY_HOUR ). The MySQL extensions try to accomplish what the combination DATE_TRUNC( ) and DATE_PART( ) do in PostgreSQL. MySQL supports the dateparts listed in Table 4-5. Table 4-5: MySQL Dateparts Type value Meaning Expected format SECOND Seconds SECONDS MINUTE Minutes MINUTES 168 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 MySQL 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