Posts

Showing posts from November, 2019

MySQL DATE_FORMAT() Function

MySQL  DATE_FORMAT()  Function ❮ MySQL Functions Example Format a date: SELECT  DATE_FORMAT( "2017-06-15" ,  "%Y" ); Try it Yourself » Definition and Usage The DATE_FORMAT() function formats a date as specified. Syntax DATE_FORMAT( date ,  format ) Resource:  https://www.w3schools.com/sql/func_mysql_date_format.asp

MySQL ROUND() Function

MySQL  ROUND()  Function ❮ MySQL Functions Example Round the number to 2 decimal places: SELECT  ROUND( 135.375 ,  2 ); Try it Yourself » Definition and Usage The ROUND() function rounds a number to a specified number of decimal places. Note:  See also the  FLOOR() ,  CEIL() ,  CEILING() , and  TRUNCATE()  functions. Syntax ROUND( number ,  decimals ) Resource: https://www.w3schools.com/sql/func_mysql_round.asp

MySql LOCATE() function

MySQL  LOCATE()  Function ❮ MySQL Functions Example Search for "3" in string "W3Schools.com", and return position: SELECT  LOCATE( "3" ,  "W3Schools.com" )  AS  MatchPosition; Try it Yourself » Definition and Usage The LOCATE() function returns the position of the first occurrence of a substring in a string. If the substring is not found within the original string, this function returns 0. This function performs a case-insensitive search. Note:  This function is equal to the  POSITION()  function. Syntax LOCATE( substring ,  string ,  start ) Resource: https://www.w3schools.com/sql/func_mysql_locate.asp

Mysql SUBSTRING() function

MySQL  SUBSTRING()  Function ❮ MySQL Functions Example Extract a substring from a string (start at position 5, extract 3 characters): SELECT  SUBSTRING( "SQL Tutorial" ,  5 ,  3 )  AS  ExtractString; Try it Yourself » Definition and Usage The SUBSTRING() function extracts a substring from a string (starting at any position). Note:  The  SUBSTR()  and  MID()  functions equals to the SUBSTRING() function. Syntax SUBSTRING( string ,  start ,  length ) OR: SUBSTRING( string  FROM  start  FOR  length ) Resource:  https://www.w3schools.com/sql/func_mysql_substring.asp

Mysql LEFT() function

MySQL  LEFT()  Function ❮ MySQL Functions Example Extract 3 characters from a string (starting from left): SELECT   LEFT ( "SQL Tutorial" ,  3 )  AS  ExtractString; Try it Yourself » Definition and Usage The LEFT() function extracts a number of characters from a string (starting from left). Tip:  Also look at the  RIGHT()  function. Syntax LEFT( string ,  number_of_chars ) Resource: https://www.w3schools.com/sql/func_mysql_left.asp

Mysql concat_ws() function

MySQL  CONCAT_WS()  Function ❮ MySQL Functions Example Add several expressions together, and add a "-" separator between them: SELECT  CONCAT_WS( "-" ,  "SQL" ,  "Tutorial" ,  "is" ,  "fun!" )  AS  ConcatenatedString; Try it Yourself » Definition and Usage The CONCAT_WS() function adds two or more expressions together with a separator. Note:  Also look at the  CONCAT()  function. Syntax CONCAT_WS( separator ,  expression1 ,  expression2 ,  expression3 ,...) Resource: https://www.w3schools.com/sql/func_mysql_concat_ws.asp