To find the difference, use the DATEDIFF() method. Let us first create a table −mysql> create table DemoTable1446 -> ( -> DueDate date -> ); Query OK, 0 rows affected (1.42 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1446 values('2019-01-21'); Query OK, 1 row affected (0.69 sec) mysql> insert into DemoTable1446 values('2019-02-01'); Query OK, 1 row affected (0.44 sec) mysql> insert into DemoTable1446 values('2019-09-30'); Query OK, 1 row affected (0.16 sec)Display all records from the table using select statement −mysql> select * from DemoTable1446;This will produce the following output −+------------+ | DueDate ... Read More
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
To get string as date, use STR_TO_DATE() method. Let us first create a table −mysql> create table DemoTable1445 -> ( -> AdmissionDate varchar(20) -> ); Query OK, 0 rows affected (0.46 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1445 values('01.10.2019'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable1445 values('31.12.2018'); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable1445 values('01.02.2017'); Query OK, 1 row affected (0.11 sec)Display all records from the table using select −mysql> select * from DemoTable1445;This will produce the following output −+---------------+ | AdmissionDate | ... Read More
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
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
jQuery.bind() methodThe bind() method in jQuery attaches one or more event handlers for the selected elements.Note: The jQuery bind() method deprecated in jQuery.ExampleYou can try to run the following code to learn how to work with bind() method in jQuery:Live Demo $(document).ready(function(){ $("div").bind("click", function(){ alert("Hello World!"); }); }); Click me! I am an alert! jQuery.live() methodThe live( type, fn ) method binds a handler to an event (like click) for all current - and future - matched element. It can also bind ... Read More
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.
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
To find all siblings of currently selected object in jQuery, use the siblings() method. The siblings( [selector] ) method gets a set of elements containing all of the unique siblings of each of the matched set of elements.Here is the description of all the parameters used by this method −selector − This is optional selector to filter the sibling Elements with.ExampleYou can try to run the following code to learn how to find all siblings:Live Demo jQuery siblings() method $(document).ready(function(){ $("p").siblings('.selected').addClass("highlight"); }); .highlight { background:yellow; } Hello Hello Again And Again
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
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP