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 169 Wednesday, November 29, 2000 4:43 PM Table 4-5: MySQL Dateparts (continued) Type value Meaning Expected format HOUR Hours HOURS DAY Days DAYS MONTH Months MONTHS YEAR Years YEARS MINUTE_SECOND Minutes and seconds MINUTES:SECONDS HOUR_MINUTE Hours and minutes HOURS:MINUTES DAY_HOUR Days and hours DAYS HOURS YEAR_MONTH Years and months YEARS-MONTHS HOUR_SECOND Hours, minutes, seconds HOURS:MINUTES:SECONDS DAY_MINUTE Days, hours, minutes DAYS HOURS:MINUTES DAY_SECOND Days, hours, minutes, DAYSHOURS:MINUTES:SECONDS seconds Example This example extracts dateparts from several datetime values: /* On MySQL */ SELECT EXTRACT(YEAR FROM “2013-07-02″); -> 1999 SELECT EXTRACT(YEAR_MONTH FROM “2013-07-02 01:02:03″); -> 199907 SELECT EXTRACT(DAY_MINUTE FROM “2013-07-02 01:02:03″); -> 20102 POSITION The POSITION function returns an integer that indicates the starting position of a string within the search string. MySQL and PostgreSQL support the POSITION function with no variation from the SQL99 syntax. PostgreSQL has a synonymous function, TEXTPOS, while MySQL has the synonymous function, LOCATE. Oracle s equivalent function is called INSTR. Microsoft SQL Server has both CHARINDEX and PATINDEX. The CHARINDEX and PATINDEX are very similar, except that PATINDEX allows the use of wildcard characters in the search criteria. For example: /* On MySQL */ SELECT LOCATE(’bar’, ‘foobar’); -> 4 /* On MySQL and PostgreSQL */ SELECT POSITION(’fu’ IN ’snafhu’); -> 0 /* On Microsoft SQL Server */ SELECT CHARINDEX( ‘de’, ‘abcdefg’ ) GO -> 4 Functions POSITION 169

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