Update Column A or B in MySQL Based on Conditions

AmitDiwan
Updated on 31-Dec-2019 07:59:15

2K+ Views

For this, use IF() with IS NULL property. Let us first create a table −mysql> create table DemoTable1976    (    FirstName varchar(20),    LastName varchar(20)    ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1976 values('John', 'Doe'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1976 values('John', NULL); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1976 values(NULL, 'Miller'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1976 values('Chris', 'Brown'); Query OK, 1 row affected (0.00 sec)Display all records from the table ... Read More

imagecolortransparent Function in PHP

George John
Updated on 31-Dec-2019 07:58:19

335 Views

The imagecolortransparent() function is used to set the color of a transparent image.Syntaximagecolortransparent ( img, color )Parametersimg: Create image with imagecreatetruecolor() function.color: Color identifier created with imagecolorallocate().ReturnThe imagecolortransparent() function returns the identifier of the new transparent color. The return value is -1 if color is not specified and the image has no transparent color.ExampleThe following is an exampleOutputThe following is the output:

jQuery Effect Show Method

AmitDiwan
Updated on 31-Dec-2019 07:58:16

373 Views

The show() method in jQuery is used to display the hidden element.SyntaxThe syntax is as follows −$(selector).show(speed, easing, callback)Above, the parameter speed is the speed of the show effect, whereas easing is the speed of the element in different points of the animation. The callback function is a function that executes after the show() method completes.Let us now see an example to implement the jQuery show() method −Example Live Demo    $(document).ready(function(){       $(".btnhide").click(function(){          $("p").hide();       });       $(".btnshow").click(function(){          $("p").show();       }); ... Read More

Count Column Values from Two Columns Excluding Nulls in MySQL

AmitDiwan
Updated on 31-Dec-2019 07:56:49

233 Views

Let us first create a table −mysql> create table DemoTable1975    (    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 DemoTable1975 values('John', 45); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1975 values('Chris', 67); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1975 values('David', 59); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1975 values('Bob', NULL); Query OK, 1 row affected (0.00 sec)Display all records from the table using select statement −mysql> select * from DemoTable1975;This ... Read More

Dynamic SQL to Get Parameter for New Table in Stored Procedure

AmitDiwan
Updated on 31-Dec-2019 07:54:52

526 Views

For this, use prepared statement. Let us first create a table −mysql> create table DemoTable1973    (    StudentId int,    StudentName varchar(20)    ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1973 values(101, 'Chris'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1973 values(102, 'John Doe'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1973 values(103, 'David'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1973 values(104, 'John Smith'); Query OK, 1 row affected (0.00 sec)Display all records from the table using ... Read More

MySQL Query to Get a Specific Row from Rows

AmitDiwan
Updated on 31-Dec-2019 07:52:57

464 Views

Let us first create a table −mysql> create table DemoTable1972    (    Section char(1),    StudentName varchar(20)    ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1972 values('D', 'Chris'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1972 values('B', 'David'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1972 values('A', 'Mike'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1972 values('C', 'Carol'); Query OK, 1 row affected (0.00 sec)Display all records from the table using select statement −mysql> select * from DemoTable1972;This ... Read More

MySQL Procedure with SELECT to Return the Entire Table

AmitDiwan
Updated on 31-Dec-2019 07:49:56

3K+ Views

Let us first create a table −mysql> create table DemoTable1971    (    StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    StudentName varchar(20),    StudentPassword int    ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1971(StudentName, StudentPassword) values('John', '123456'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1971(StudentName, StudentPassword) values('Chris', '123456'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1971(StudentName, StudentPassword) values('David', '123456'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1971(StudentName, StudentPassword) values('Mike', '123456'); Query OK, 1 row affected (0.00 sec)Display all ... Read More

imagecolorresolve Function in PHP

Arjun Thakur
Updated on 31-Dec-2019 07:48:35

39 Views

The imagecolorresolve() function gets the index of the specified color or its closest possible alternative.Syntaximagecolorresolve (img , red , green , blue )Parametersimg: Image created with imagecreatetruecolor() function.red: The value of red component.green: The value of green component.blue: The value of blue component.ReturnThe imagecolorresolve() function returns the color index.ExampleThe following is an example Live DemoOutputThe following is the output:Array ( [0] => 128 [1] => 129 [2] => 130 )

imagecolorsTotal Function in PHP

Chandu yadav
Updated on 31-Dec-2019 07:47:13

72 Views

The imagecolorstotal() function gets the count of colors in an image's paletteSyntaximagecolorstotal (img)Parametersimg: Image created with imagecreatetruecolor().ReturnThe imagecolorstotal() function returns the number of colors in an image palette.ExampleThe following is an example Live DemoOutputThe following is the output:Number of Colors = 128

jQuery Element Siblings Selector

AmitDiwan
Updated on 31-Dec-2019 07:46:45

162 Views

The element ~ siblings selector in jQuery is used to select all elements that are siblings of the specified "element".SyntaxThe syntax is as follows −("ele ~ siblings")Above, the parameter ele is any valid selector, whereas siblings are the siblings of the ele parameter.ExampleLet us now see an example to implement the jQuery element ~ siblings selector − Live Demo    $(document).ready(function(){       $("div ~ p").css("color", "orange");    }); div {    border:1px solid black;    padding:10px; } Demo Heading This is demo text. span outside p element This is demo text. ... Read More

Advertisements