You can update boolean value using UPDATE command. If you use the BOOLEAN data type, MySQL internally convert it into tinyint(1). It can takes true or false literal in which true indicates 1 to tinyint(1) and false indicates 0 to tinyint(1).The syntax is as follows −UPDATE yourTableName SET yourColumnName = yourValue WHERE yourCondition;To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table UpdateBooleans -> ( -> Id int NOT NULL AUTO_INCREMENT, -> isSuccessful BOOLEAN, -> PRIMARY KEY(Id) -> ); Query OK, 0 rows ... Read More
Definition and UsageThe pi () function returns the value of mathematical constant Π. It returns a float value 3.14159265359 which is equal to predefined constant defined in PHP - M_PISyntaxpi ( void ) : floatParametersThis function requires no parametersReturn ValuesPHP pi() function returnsthe mathematical constant Π and is equal to predefined mathematical constant M-PI. Instead of using M_PI, we can use pi() function in mathematical expressions.PHP VersionThis function is available in PHP versions 4.x, PHP 5.x as well as PHP 7.x.Example Live DemoFollowing exampleuses pi() function in calculation of area of circle.OutputThis will produce following result −area of circle with radius = 5is ... Read More
Definition and UsageThe 'mt' prefix in function's name stands for Mersenne Twister. The mt_rand() function returns an integer using Mersenne Twister Random Number Generator method. This function is a drop-in replacement for PHP's rand() function. default range is between 0 and platform specific mt_getrandmax(). On 64 bit Windows OS, it is 2147483647. The mt_rand() function can be called without arguments (in which case the default range will be used) or by specifying min and max parameters.This function always returns an integer.Syntaxmt_rand ( void ) : int mt_rand ( int $min , int $max ) : intParametersSr.NoParameter & Description1minlower limit of ... Read More
Overriding is a one of the mechanisms to achieve polymorphism. This is the case when we have two classes where, one inherits the properties of another using the extends keyword and, these two classes same method including parameters and return type (say, sample).Since it is inheritance. If we instantiate the subclass a copy of superclass’s members is created in the subclass object and, thus both methods are available to the subclass.When we invoke this method (sample) JVM calls the respective method based on the object used to call the method.Overriding final methodsNo, you cannot override final method in java. If ... Read More
Definition and UsageThe octdec() function is used to convert an octal number to decimal number equivalent. The function takes a string with octal representation as argument and retuns an integer.For example octdec('10') returns 8.Syntaxoctdec ( string $octal_string ) : numberParametersSr.NoParameter & Description1octal_stringA string containing the octal number to be convertedReturn ValuesPHP octdec() function returns a decimal equivalent of given octal representation.PHP VersionThis function is available in PHP versions 4.x, PHP 5.x as well as PHP 7.x.Example Live DemoFollowing example converts '10' from octal to decimal number system. −OutputThis will produce following result −octdec(10) = 8Example Live DemoIf there is Any character other ... Read More
Definition and UsagePrefix 'mt' in function's name stands for Mersenne Twister. The mt_srand() function is used to seed the Mersenne Twister random number generaror. Seeding initializes the random number generator. Most random number generators need initial seeding. In PHP, use of mt_srand() function is optional as it is done automatically.This function doen't have any return value.Syntaxmt_srand ([ int $seed [, int $mode = MT_RAND_MT19937 ]] ) : voidParametersSr.NoParameter & Description1seedan integer to be used as seed. If not given, a random number is given2modeUse one of the following constants to specify mode of implementationMT_RAND_MT19937 uses fixed Mersenne Twister implementationMT_RAND_PHP uses ... Read More
No, definer part is not compulsory when you are creating a stored procedure. It is used when you want to create a definer.Check all the user and host from the MySQL.user table −mysql> select user, host from mysql.user;The following is the output −+------------------+-----------+ | user | host | +------------------+-----------+ | Manish | % | | User2 | % | | mysql.infoschema | % | | mysql.session | % ... Read More
Definition and UsageThe 'mt' prefix in function's name stands for Mersenne Twister. The mt_ getrandmax() function returns largest integer that can be used in PHP. This function uses Mersenne Twister Random Number Generator method. Value returned by this function serves as the upper limit for mt_rand() function to generate random number.This function always returns an integer.Syntaxmt_getrandmax ( void ) : intParametersSr.NoParameter & Description1This function needs no parametersReturn ValuesPHP mt_getrandmax() function use Mersenne Twister Random Number Generator method. and returns largest possible integer that can be used in PHP. On 64 bit Windows, the number is 2147483647PHP VersionThis function is available ... Read More
You can use GROUP BY command for select with distinct id. The syntax is as follows −SELECT *FROM yourTableName GROUP BY yourColumnName;To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table DistinctIdDemo -> ( -> Id int, -> Name varchar(20), -> Age int -> ); Query OK, 0 rows affected (1.03 sec)Insert some records in the table using insert command. Here, we have added ID with duplicate values.The query is as follows −mysql> insert into DistinctIdDemo values(1, 'Mike', 23); Query OK, 1 row ... Read More
Definition and UsageThe min () function returns lowest element in array, or lowest amongst two or more comma separated parameters.Syntaxmin ( array $values ) : mixedOrmin ( mixed $value1 [, mixed $... ] ) : mixedParametersSr.NoParameter & Description1valuesIf only one parameter is given, it should be an array of valaues which may be of same or different types2value1, value2, ..If two or more parameters aregiven, they should be any comparable values of same or different typesReturn ValuesPHP min() function returns lowest value from the array parameter or sequence of values. Standard comparison operators are applicable. If multiple values of different types evaluate ... Read More