Set a Specific Value for the First Three Column Values in MySQL

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

248 Views

To set a specific value for only 1st three values, you need to use LIMIT 3. Let us first create a table −mysql> create table DemoTable1968    (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    Name varchar(20)    ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1968(Name) values('Chris'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1968(Name) values('David'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1968(Name) values('Sam'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1968(Name) values('Mike'); Query OK, 1 ... Read More

imagecopymerge Function in PHP

Chandu yadav
Updated on 31-Dec-2019 07:41:39

818 Views

The imagecopymerge() function copy and merge part of an image.Syntaximagecopymerge ( dst_img, src_img, dst_x, dst_y, src_x, src_y, src_w, src_h, pct )Parametersdst_im Set destination image link resource.src_im Set source image link resource.dst_x Set x-coordinate of destination point.dst_y Set y-coordinate of destination point.src_x Set x-coordinate of source point.src_y Set y-coordinate of source point.src_w Set source width.src_h Set source height.pct The two images will be merged according to pct which can range from 0 to 100.ReturnThe imagecopymerge() function returns the TRUE on success or FALSE on failure.ExampleThe following is an example:OutputThe following is the output displaying the merge of two images:ExampleLet us see ... Read More

imagecharup Function in PHP

Ankith Reddy
Updated on 31-Dec-2019 07:40:15

77 Views

The imagecharup() function is used to draw a character vertically.Syntaximagecharup( img, font, x, y, c, color )Parametersimg: Create an image with imagecreatetruecolor()font: Sets the font size. It can be 1, 2, 3, 4, 5 for built-in fonts in latin2 encodingx: x-coordinatey: y-coordinatec: character to be drawncolor: color identifierReturnThe imagecharup() function returns TRUE on success or FALSE on failure.ExampleThe following is an example:OutputThe following is the output:ExampleLet us see another example:OutputThe following is the output that draws character E with different dimensions:

jQuery parentsUntil() Method with Example

AmitDiwan
Updated on 31-Dec-2019 07:40:08

276 Views

The parentsUntil() method in jQuery is used to return all ancestor elements between the selector and stop parameter value.SyntaxThe syntax is as follows −$(selector).parentsUntil(stop, filter)Above, the stop parameter is a selector expression, element or jQuery object. The filter parameter is a selector expression that narrows down the search for ancestors between the selector and the stops parameter.ExampleLet us now see an example to implement the jQuery parentsUntil() method − Live Demo div {    width:600px; } .demo * {    display: block;    border: 2px solid yellow;    color: blue;    padding: 10px;    margin: 10px; } ... Read More

imagechar Function in PHP

Chandu yadav
Updated on 31-Dec-2019 07:38:45

175 Views

The imagechar() function draws a character horizontally.Syntaxbool imagechar( img, font, x, y, ch, color )Parametersimg: Creating an image with imagecreatetruecolor().font: Set font sizex: x-coordinatey: y-coordinatec: The character to draw.color: A color identifier created with imagecolorallocate().ReturnThe imagechar() function returns TRUE on success or FALSE on failure.ExampleThe following is an example:OutputThe following is the output:ExampleLet us see another example wherein we are drawing a character with different coordinates and height/ width as shown in the above example:OutputThe following is the output:

Select and Insert Values with Preceding Zeros in a MySQL Table

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

155 Views

For this, you can use INSERT INTO SELECT statement along with LPAD(). Let us first create a table −mysql> create table DemoTable1967    (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    UserId varchar(20)    ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1967(UserId)    select LPAD(COALESCE(MAX(id), 0) + 1, 3, '0') from DemoTable1967; Query OK, 1 row affected (0.00 sec) Records: 1  Duplicates: 0  Warnings: 0 mysql> insert into DemoTable1967(UserId)    select LPAD(COALESCE(MAX(id), 0) + 1, 3, '0') from DemoTable1967; Query OK, 1 row affected (0.00 sec) ... Read More

Use IF-ELSE Condition in SELECT in MySQL

AmitDiwan
Updated on 31-Dec-2019 07:36:35

1K+ Views

Let us first create a table −mysql> create table DemoTable1966    (    UserId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    UserName varchar(20),    PhotoLiked int    ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1966(UserName, PhotoLiked) values('Chris', 57); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1966(UserName, PhotoLiked) values('David', 100); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1966(UserName, PhotoLiked) values('Mike', 68); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1966(UserName, PhotoLiked) values('Sam', 78); Query OK, 1 row affected (0.00 sec)Display all ... Read More

jQuery prop() Method with Examples

AmitDiwan
Updated on 31-Dec-2019 07:35:43

648 Views

The prop() method in jQuery is used to set or return the properties and values of the selected elements.SyntaxThe syntax is as follows −$(selector).prop(property)ExampleLet us now see an example to implement the jQuery prop() method − Live Demo    $(document).ready(function(){       $("button").click(function(){          var $val = $("div");          $val.prop("font-size", "1.6em");          $val.append("Property value = " + $val.prop("font-size"));       });    }); Adding Property Property OutputThis will produce the following output −Click the button to add a property −

Identify Column Existence in All Tables with MySQL

AmitDiwan
Updated on 31-Dec-2019 07:34:29

195 Views

To identify a column name, use INFORMATION_SCHEMA.COLUMNS in MySQL. Here’s the syntax −select table_name, column_name from INFORMATION_SCHEMA.COLUMNS where table_schema = SCHEMA() andcolumn_name='anyColumnName';Let us implement the above query in order to identify a column with its existence in all tables. Here, we are finding the existence of column EmployeeAge −mysql> select table_name, column_name    FROM INFORMATION_SCHEMA.COLUMNS    WHERE table_schema = SCHEMA()    AND column_name='EmployeeAge';This will produce the following output displaying the tables with specific column “EmployeeAge” −+---------------+-------------+ | TABLE_NAME    | COLUMN_NAME | +---------------+-------------+ | demotable1153 | EmployeeAge | | demotable1297 | EmployeeAge | | demotable1303 | EmployeeAge | | demotable1328 ... Read More

jQuery Position with Examples

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

213 Views

The position() method in jQuery is used to return the position of the first matched element. It returns the top and left positions in pixels.SyntaxThe syntax is as follows −$(selector).position()ExampleLet us now see an example to implement the jQuery position() method − Live Demo    $(document).ready(function(){       $("button").click(function(){          alert("Top position: " + ($("h3").position()).top + " Left position: " + ($("h3").position()).left);       });    }); Heading One Heading Two Heading Three Position of h3 element OutputThis will produce the following output −Click the button to get left and top position of element −

Advertisements