MySQL ORDER BY with Numeric User Defined Variable

AmitDiwan
Updated on 27-Dec-2019 07:05:19

393 Views

Let us first create a table −mysql> create table DemoTable1898    (    Number int    ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1898 values(10); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1898 values(70); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1898 values(30); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1898 values(50); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1898 values(40); Query OK, 1 row affected (0.00 sec)Display all records from the table using select statement ... Read More

Convert Character to Uppercase in MySQL

AmitDiwan
Updated on 27-Dec-2019 07:04:08

137 Views

Let us first create a table −mysql> create table DemoTable1897    (    Name varchar(20)    ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1897 values('john'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1897 values('Chris'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1897 values('jace'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1897 values('David'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1897 values('Chris'); Query OK, 1 row affected (0.00 sec)Display all records from the table using select statement ... Read More

Rand Function in PHP

karthikeya Boyini
Updated on 27-Dec-2019 07:03:56

231 Views

The rand() function gets a random number. You can also set a range to get random number from that particular range.Syntaxrand(); or rand(min_range,max_range);Parametersmin_range − Default is 0. This is the lowest number to be Returned.max_range − This is the highest number to be Returned.ReturnThe rand() function Returns a random integer between min_range and max_range.Example Live DemoOutput158122727010940012273063370521512118877894804115835633ExampleLet us see another example − Live DemoOutput4114

rad2deg Function in PHP

Samual Sam
Updated on 27-Dec-2019 07:02:47

78 Views

The rad2deg() function converts radian value to degree value. It Returns the equivalent of radia value val in degrees.Syntaxrad2deg(val)Parametersval − The radian value to be converted into degree.ReturnThe rad2deg() function Returns the equivalent of val in degrees.Example Live DemoOutput180ExampleLet us see another example − Live DemoOutput90ExampleLet us see another example − Live DemoOutput22.5

Get a Single Value from a Specific MySQL Row

AmitDiwan
Updated on 27-Dec-2019 07:02:32

2K+ Views

For this, use SELECT INTO variable with where clause. Let us first create a table −mysql> create table DemoTable1896    (    StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    StudentName varchar(20),    StudentMarks int    ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1896(StudentName, StudentMarks) values('Chris', 56); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1896(StudentName, StudentMarks) values('David', 98); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1896(StudentName, StudentMarks) values('Mike', 89); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1896(StudentName, StudentMarks) values('Sam', ... Read More

Pow Function in PHP

karthikeya Boyini
Updated on 27-Dec-2019 07:01:25

219 Views

The pow() function Returns a raised to the power of b.Syntaxpow(a,b)Parametersa − The baseb − The exponentReturnThe pow() function Returns a raised to the power of b.Example Live DemoOutput243ExampleLet us see another example − Live DemoOutput4096-5.0805263425291E-5ExampleLet us see another example − Live DemoOutputNAN

Assign Value to MySQL Column That Must Not Be Empty

AmitDiwan
Updated on 27-Dec-2019 06:58:48

405 Views

Define with NOT NULL, if a column must not be empty. Let us first create a table with one of the columns as NOT NULL −mysql> create table DemoTable1895    (    Id int NOT NULL,    FirstName varchar(20),    LastName varchar(20) NOT NULL    ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1895 values(100, 'John', 'Smith'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1895 values(NULL, 'Chris', 'Brown'); ERROR 1048 (23000): Column 'Id' cannot be null mysql> insert into DemoTable1895 values(102, 'Carol', NULL); ERROR 1048 (23000): ... Read More

Pi Function in PHP

Samual Sam
Updated on 27-Dec-2019 06:57:57

147 Views

The pi() function Returns the value of Pi (π).Syntaxpi()ParametersNAReturnThe pi() function Returns the approximate value of PI. This value is a floating point value.3.1415926535898Example Live DemoOutput3.1415926535898ExampleLet us see another example to get the value of PI Live DemoOutput3.1415926535898

Set MySQL Field with Current Date Unix Timestamp Now

AmitDiwan
Updated on 27-Dec-2019 06:57:19

583 Views

For this, use unix_timestamp(). Let us first create a table −mysql> create table DemoTable1894    (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    DueTime int    ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1894 values(); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1894 values(); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1894 values(); Query OK, 1 row affected (0.00 sec)Display all records from the table using select statement −mysql> select * from DemoTable1894;This will produce the following output −+----+---------+ | ... Read More

octdec Function in PHP

karthikeya Boyini
Updated on 27-Dec-2019 06:57:16

79 Views

The octdec() function converts octal to decimal.Syntaxoctdec(val)Parametersval − the octal string to convertReturnThe octdec() function Returns the decimal equivalent of the specified octal number.Example Live DemoOutputa80ExampleLet us see another example − Live DemoOutput120170

Advertisements