Return Maximum Value from Records in MySQL

AmitDiwan
Updated on 10-Dec-2019 05:53:12

204 Views

Let us first create a table −mysql> create table DemoTable1449    -> (    -> PlayerId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> PlayerScore int    -> ); Query OK, 0 rows affected (0.69 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1449(PlayerScore) values(1040); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable1449(PlayerScore) values(1450); Query OK, 1 row affected (0.34 sec) mysql> insert into DemoTable1449(PlayerScore) values(1890); Query OK, 1 row affected (0.72 sec) mysql> insert into DemoTable1449(PlayerScore) values(1650); Query OK, 1 row affected (0.25 sec)Display all records from the table using select statement ... Read More

Check Current Date in a Given Date Range Using MySQL Query

AmitDiwan
Updated on 10-Dec-2019 05:50:53

899 Views

Let us first create a table −mysql> create table DemoTable1448    -> (    -> StartDate date,    -> EndDate date    -> ); Query OK, 0 rows affected (0.46 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1448 values('2019-01-21', '2019-03-22'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable1448 values('2019-04-05', '2019-10-10'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable1448 values('2019-10-01', '2019-10-29'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable1448 values('2018-12-31', '2019-12-31'); Query OK, 1 row affected (0.12 sec)Display all records from the table using select statement −mysql> ... Read More

MySQL Query to Fetch Records from Comma-Separated Values

AmitDiwan
Updated on 10-Dec-2019 05:47:04

197 Views

For this, you can use REGEXP in MySQL. Let’s say you want the row records wherein any of the comma separated value is 90. For this, use regular expression.Let us first create a table −mysql> create table DemoTable1447    -> (    -> Value varchar(100)    -> ); Query OK, 0 rows affected (0.58 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1447 values('19, 58, 90, 56'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable1447 values('56, 89, 99, 100'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable1447 values('75, 76, 65, ... Read More

Set Conditions in a MySQL Stored Procedure

AmitDiwan
Updated on 10-Dec-2019 05:40:40

783 Views

To set conditions in a stored procedure, use IF...ELSE in MySQL. Following is the syntax for if-else −IF yourCondition then       yourStatement1,  ELSE           yourStatement2,  END IF;Let us implement the above syntax in a stored procedure −mysql> DELIMITER // mysql> CREATE PROCEDURE IF_ELSE_DEMO(IN value int)    -> BEGIN    ->    SET @val=value;    ->    IF @val > 10 then    ->       select concat(@val, ' is greater than 10');    ->    ELSE    ->        select concat(@val, ' is less than 10 ');    ->    END ... Read More

Difference Between jQuery map and jQuery each Functions

David Meador
Updated on 09-Dec-2019 11:12:13

420 Views

jQuery map functionThe map method translates a set of elements in the jQuery object into another set of values in a jQuery array which may, or may not contain elements.ExampleYou can try to run the following code to learn how to work with jQuery.map() method:Live Demo           jQuery Map Method                              $(document).ready(function(){                         var mappedItems = $("li").map(function (index) {                var replacement = ... Read More

Difference Between jQuery html() and jQuery append() Methods

David Meador
Updated on 09-Dec-2019 11:05:28

307 Views

jQuery.html() methodThe html() method gets the html contents (innerHTML) of the first matched element. This property is not available on XML documents.ExampleYou can try to run the following code to learn how to work with jQuery.html() method in jQuery:Live Demo           jQuery html() method                          $(document).ready(function() {             $("div").click(function () {                var content = $(this).html();                $("#result").html(content);             });   ... Read More

Add Previous Element to Current jQuery Selection

David Meador
Updated on 09-Dec-2019 10:59:39

648 Views

To add the previous element to current jQuery selection, use the insertBefore() method.ExampleYou can try to run the following code to learn how to work with insertBefore() method:Live Demo $(document).ready(function(){     $("button").click(function(){         $("Demo text").insertBefore("p");     }); }); Insert This is a paragraph.

Understanding jQuery Traversing Siblings

David Meador
Updated on 09-Dec-2019 10:58:06

175 Views

jQuery traversing siblings  is traverse to find siblings of an elements using jQuery. To traverse sideways in DOM tree, use the following methods:siblings(): This returns all the siblings elements of the selected element.next(): This method returns the next sibling element of the selected element.nextAll(): This method returns all next sibling element of the selected element.nextUntil(): The nextUntil() method returns all next sibling elements between two given arguments.prev():This method returns the previous sibling element of the selected element.prevAll(): This method returns all previous sibling element of the selected elementprevUntil():The prevUntil() method returns all next previous sibling elements between two given arguments.Let’s ... Read More

Fastest Method Between Children and Find in jQuery

Amit D
Updated on 09-Dec-2019 10:32:43

535 Views

The answer to which one is the fastest between children() and find() method depends on the usage. The find() method traverses the entire Dom whereas the children() method gets the immediate children of the node.jQuery children() methodThe children() method is to get the immediate children of the node. The children( [selector] ) method gets a set of elements containing all of the unique immediate children of each of the matched set of elements.Here is the description of all the parameters used by this method −selector − This is an optional argument to filter out all the childrens. If not supplied then ... Read More

Difference Between Grep and Filter in jQuery

David Meador
Updated on 09-Dec-2019 09:58:26

1K+ Views

The grep() method finds an element and the filter() method returns elements matching a specific criteria.jQuery grep functionExampleThe grep() function is used to find an element of an array. You can try to run the following code to learn how to work with grep(), Live Demo   jQuery grep() function     div {     color: blue;   }   p {     color: red;     margin: 0;   }       var arr1 = [ 1, 7, 4, 8, 6, 1, 9, 5, 3, 7, ... Read More

Advertisements