Purge Binary log

MySQL Cluster

If you have enabled binary logging for the point-in-time recovery (or using replication in your environment) option and forgot to purge it then it may eat up memory in no time, so to “purge” binary logs from production server follow the steps(depending upon your environment) List the current binary logs List the current binary logs … Read more

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

PHP – MySQL : Create Database

php-mysql

  [root@mysqlDB]# mysqladmin -u root -p create eduguru Enter password:****** This will create a MySQL database eduguru. This is a simple example to create database called eduguru. Example: <?php $dbhost = ‘localhost:3036’; //If mysql server is on same server $dbuser = ‘root’; //mysql user who has the permission to create database $dbpass = ‘rootpassword’; //mysql user’s password … 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

mysql locate function

MySQL Cluster

MySQL LOCATE() returns the position of the first occurrence of a string within a string. Both of these strings are passed as arguments. An optional argument may be used to specify from which position of the string (i.e. string to be searched) searching will start. If this position is not mentioned, searching starts from the … Read more

mysql limit clause

MySQL Cluster

What is MySQL limit clause? The LIMIT clause is used in the SELECT statement to constrain the number of rows in a result set. The LIMIT clause accepts one or two arguments. The values of both arguments must be zero or positive integers. It limits the Data Selections from a MySQL Database. The LIMIT clause … Read more

mysql length function

MySQL Cluster

Description: MySQL LENGTH() returns the length of a given string. Syntax: LENGTH (str) Argument: Name      Description str            A string whose length is to be returned. Example of MySQL LENGTH() function mysql> SELECT LENGTH(NULL); Result: NULL mysql> SELECT LENGTH(”); Result: 0 mysql> SELECT LENGTH(‘ ‘); Result: 1 mysql> SELECT … Read more

mysql concat function

MySQL Cluster

MySQL CONCAT function is used to concatenate two strings to form a single string. Description: MySQL CONCAT() function is used to add two or more strings. There may be one or more arguments. Returns the string that results from concatenating the arguments. Returns a non binary string, if all arguments are non binary strings. Returns … Read more

MySQL substring function

MySQL Cluster

MySQL SUBSTRING() returns a specified number of characters from a particular position of a given string. Syntax: SUBSTRING(str, pos, len) or SUBSTRING(str FROM pos FOR len) Arguments Name       Description str              A string. pos             Starting position. len         … Read more

mysql if function

MySQL Cluster

Syntax: IF(expr,if_true_expr,if_false_expr) MySQL IF function is control flow functions that returns a value based on a condition. The IF function is sometimes referred to as IF ELSE or IF THEN ELSE function. If the expr evaluates to TRUE i.e., expr is not NULL and expr is not 0, the IF function returns the if_true_expr , … Read more