MySQL Addtime() : Adding time to datetime

MySQL Addtime() : Adding time to datetime The ADDTIME() function adds a time interval to a time/datetime and then returns the time/datetime. Syntax ADDTIME(datetime, addtime) Parameter Values Parameter Description datetime Required.  The time/datetime to be modified addtime Required. The time interval to add to datetime. Both positive and negative values are allowed Example: SELECT ADDTIME(“2021-06-03 09:34:21”, “2”); Output: … Read more

time_to_sec MySQL function

MySQL Function

time_to_sec MySQL function The TIME_TO_SEC() function converts a time value into seconds. SELECT TIME_TO_SEC(“19:30:10”); Output: 70210 SELECT TIME_TO_SEC(“-03:30:00”); Output: -12600 PHP MySQL Program example of time_to_sec <!doctype html> <html lang=”en”> <head> <meta charset=”utf-8″> <meta name=”viewport” content=”width=device-width, initial-scale=1″> <title>example-time_to_sec-function – php mysql examples | w3resource</title> <meta name=”description” content=”PHP MySQL PDO Example”> <link rel=”stylesheet” href=”https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css”> </head> <body> … Read more

MySQL UNION Operator

mysql 5.7

MySQL UNION Operator The UNION operator is used to combine the result-set of two or more SELECT statements. Each SELECT statement within UNION must have the same number of columns The columns must also have similar data types The columns in each SELECT statement must also be in the same order Example: Basic Query: SELECT column_name(s) FROM table1 UNION SELECT column_name(s) FROM table2; … Read more

MySQL SUM function

mysql 5.7

MySQL SUM function The SUM() function returns the total sum of a numeric column. The SUM() function is an aggregate function that allows you to calculate the sum of a set of values or an expression. Syntax for SUM function would be as below: SELECT SUM(column_name) FROM table_name WHERE condition; You can also use distinct value while sum function SELECT SUM(distinct column_name) FROM table_name WHERE condition; If … Read more

MySQL AVG() function

mysql 5.7

MySQL AVG() function AVG function to calculate the average value of a set of values or an expression. The AVG() function returns the average value of a numeric column. If the function does not find a matching row, it returns NULL The DISTINCT option can also be used to return the average of the distinct values of expr. … Read more

MySQL count function

mysql 5.7

MySQL count function The COUNT() function returns the number of rows that matches a specified criteria. COUNT function to count the number rows in a table. The return type of the COUNT function is BIGINT. The COUNT function will return zero if there was no matching row found. The COUNT(*) function returns the number of rows in a … Read more

MySQL MIN() and MAX() Functions

mysql 5.7

MySQL MIN() and MAX() Functions   The MIN() function returns the smallest value of the selected column and the MAX() function returns the largest value of the selected column. MIN() Syntax SELECT MIN(column_name) FROM table_name WHERE condition; MAX() Syntax SELECT MAX(column_name) FROM table_name WHERE condition;

MySQL trim function

MySQL Cluster

MySQL TRIM() function returns a string after removing all prefixes or suffixes from the given string. Syntax TRIM([{BOTH | LEADING | TRAILING} [remstr] FROM ] str) Arguments Name Description BOTH Indicates that prefixes from both left and right are to be removed. LEADING Indicates that only leading prefixes are to be removed. TRAILING Indicates that … Read more

MySQL RAND Function

MySQL Cluster

MySQL has a RAND function that can be invoked to produce random numbers between 0 and 1: mysql> SELECT RAND( ), RAND( ), RAND( ); +——————+—————–+——————+ | 0.45464584925645 | 0.1824410643265 | 0.54826780459682 | +——————+—————–+——————+ 1 row in set (0.00 sec) When invoked with an integer argument, RAND( ) uses that value to seed the random … Read more