comparison operator between in mysql

mysql between

comparison operator between in mysql General Syntax – mostly used SELECT column_name(s) FROM table_name WHERE column_name BETWEEN value1 AND value2; expr BETWEEN min AND max If expr is greater than or equal to min and expr is less than or equal to max, BETWEEN returns 1, otherwise it returns 0. This is equivalent to the expression (min <= expr AND expr <= … Read more

get the difference between two timestamps in seconds

MySQL Cluster

get the difference between two timestamps in seconds   You could use the TIMEDIFF() and the TIME_TO_SEC() functions as follows: SELECT TIME_TO_SEC(TIMEDIFF(‘2010-08-20 12:01:00’, ‘2010-08-20 12:00:00’)) diff; +——+ | diff | +——+ | 60 | +——+ 1 row in set (0.00 sec) You could also use the UNIX_TIMESTAMP() function. SELECT UNIX_TIMESTAMP(‘2010-08-20 12:01:00’) – UNIX_TIMESTAMP(‘2010-08-20 12:00:00’) diff; +——+ | diff | +——+ | … Read more

mysql length function : calculate length of a column

mysql 5.7

mysql length function : calculate length of a column Function length() Return the length of the string Usages SELECT CustomerName, LENGTH(CustomerName) AS LengthOfName FROM Customers; Tablenames Records Customers 91 Categories 8 Employees 9 OrderDetails 2155 Orders 830 Products 77 Shippers 3 Suppliers 29    

MySQL conditional expression CASE

MySQL Cluster

MySQL conditional expression CASE MySQL CASE expression is a conditional expression that allows you to construct conditions inside a query such as SELECT or WHERE clause.   CASE WHEN condition_1 THEN result_1 WHEN condition_2 THEN result_2 … ELSE result END The CASE expression returns the result such as result_1, result_2, etc., if the condition is true. If all conditions are false, then the result in the ELSE part … Read more

MySQL 5.7 features

mysql 5.7

MySQL 5.7 features MySQL 5.7 is the best release ever of the world’s most popular open source database and provides a new, advanced feature set designed to enable those who are building the next generation of web-based and embedded applications and services.  — Ref. https://www.mysql.com/why-mysql/white-papers/whats-new-mysql-5-7/ Multi-source Replication 3x Faster Performance New Optimizer Native JSON Support GIS … Read more

MySQL service uptime

MySQL Cluster

MySQL service uptime   Sometimes, we need to check the uptime for MySQL in our server. There are multiple method to check the uptime status of mysql server. Let see some of them. mysqladmin status [root@localhost ~]# mysqladmin -u root -p********* status Uptime: 225921 Threads: 10 Questions: 18469911 Slow queries: 0 Opens: 12466 Flush tables: 1 … Read more

Replication with Different Master and Slave Storage Engines

mysql master - slave replication

Replication with Different Master and Slave Storage Engines It does not matter for the replication process whether the source table on the master and the replicated table on the slave use different engine types. In fact, the default_storage_engine and storage_engine system variables are not replicated. Even this provides a number of benefits in the replication … Read more