To MySQL order string with numbers, the following is the syntax, wherein we have used ORDER BY, SUBSTR() and CAST() −SELECT *FROM yourTableName ORDER BY SUBSTR(yourColumnName FROM 1 FOR 2), CAST(SUBSTR(yourColumnName FROM 2) AS UNSIGNED);To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table OrderByStringWithNumbers -> ( -> Id int NOT NULL AUTO_INCREMENT, -> Words varchar(10), -> PRIMARY KEY(Id) -> ); Query OK, 0 rows affected (0.86 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert ... Read More
Definition and UsageMost trigonometric functions like sin, cos, tan etc require angle argument in radians. Whereas, in practice angle is represented in degrees. The rad2deg() function proves useful in conversion of radian angle to degrees.This function returns a float number such that number=rad2deg(x) where x is angle in radians. angle in radian = angle in deg *180/piFor example rad2deg(Π) is equal to 180 degreesSyntaxrad2deg ( float $number ) : floatParametersSr.NoParameter & Description1numberA float number reprsenting angle in radiansReturn ValuesPHP rad2deg() function returns a float number that represents angle in degrees.PHP VersionThis function is available in PHP versions 4.x, PHP 5.x ... Read More
Definition and UsageThe pow () function is used to compute power of a certain number. It returns xy calculation, also termed as x raised to y. PHP also provides "**" asexponentiation operator.So, pow(x, y) returns xy which is same as x**ySyntaxpow ( number $base , number $exp ) : numberParametersSr.NoParameter & Description1baseThe base to be raised2exppower to which base needs to be raisedReturn ValuesPHP pow() function returns base raised to power of exp. If both arguments are non-negative integers, the result is returned as integer, otherwise it is returned as a float.PHP VersionThis function is available in PHP versions 4.x, PHP 5.x ... Read More
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
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP