Calculate Days Between Two Dates in MySQL

AmitDiwan
Updated on 10-Dec-2019 07:39:53

377 Views

Let us first create a table −mysql> create table DemoTable1471    -> (    -> EmployeeJoiningDate date,    -> EmployeeRelievingDate date    -> ); Query OK, 0 rows affected (0.57 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1471 values('2018-06-21', '2018-12-21'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable1471 values('2017-01-19', '2019-01-31'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable1471 values('2015-12-31', '2016-03-01'); Query OK, 1 row affected (0.11 sec)Display all records from the table using select statement −mysql> select * from DemoTable1471;This will produce the following output −+---------------------+-----------------------+ | EmployeeJoiningDate | ... Read More

Select Field and Handle Nulls with MySQL

AmitDiwan
Updated on 10-Dec-2019 07:38:05

164 Views

For this, use COALESCE(). Let us first create a table −mysql> create table DemoTable1470    -> (    -> FirstName varchar(20),    -> Age int    -> ); Query OK, 0 rows affected (0.57 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1470 values('Robert', 23); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable1470 values('Bob', NULL); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable1470 values(NULL, 25); Query OK, 1 row affected (0.15 sec)Display all records from the table using select statement −mysql> select * from DemoTable1470;This will produce the following output ... Read More

Get Type Referenced by Specified Type Handle in C#

AmitDiwan
Updated on 10-Dec-2019 07:36:55

219 Views

To get the type referenced by the specified type handle, the code is as follows −Example Live Demousing System; public class Demo {    public static void Main() {       Type type1 = typeof(short);       RuntimeTypeHandle typeHandle = Type.GetTypeHandle(type1);       Type type = Type.GetTypeFromHandle(typeHandle);       Console.WriteLine("Attributes = " + type.Attributes);    } }OutputThis will produce the following output −Attributes = AutoLayout, AnsiClass, Class, Serializable, BeforeFieldInitExampleLet us see another example − Live Demousing System; public class Demo {    public static void Main() {       Type type1 = typeof(System.Type);       RuntimeTypeHandle ... Read More

Remove Index from a MySQL Table

AmitDiwan
Updated on 10-Dec-2019 07:34:41

532 Views

To remove index from a MySQL table, the syntax is as follows −alter table yourTableName drop index `yourIndexName`;Let us first create a table −Mysql> create table DemoTable1469    -> (    -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> StudentName varchar(40),    -> StudentAge int    -> ); Query OK, 0 rows affected (0.78 sec)Following is the query to add index on column name −mysql> create index `Student Name_Index` on DemoTable1469(StudentName); Query OK, 0 rows affected (0.33 sec) Records: 0  Duplicates: 0  Warnings: 0Let us check the table description −mysql> desc DemoTable1469;This will produce the following output −+-------------+-------------+------+-----+---------+----------------+ ... Read More

Convert a Specified Value to an Equivalent Boolean Value in C#

AmitDiwan
Updated on 10-Dec-2019 07:33:49

477 Views

To convert a specified value to an equivalent Boolean value, the code is as follows −Example Live Demousing System; using System.Globalization; public class Demo {    public static void Main() {       CultureInfo cultures = new CultureInfo("en-US");       String str = "true";       Console.WriteLine("Converted bool value...");       bool res = Convert.ToBoolean(str, cultures);       Console.Write("{0}", res);    } }OutputThis will produce the following output −Converted bool value... TrueExampleLet us see another example − Live Demousing System; using System.Globalization; public class Demo {    public static void Main() {       CultureInfo cultures ... Read More

Clone an Element Using jQuery

David Meador
Updated on 10-Dec-2019 07:30:02

5K+ Views

To clone an element using jQuery, use the jQuery.clone() method. The clone() method clones matched DOM Elements and select the clones.This is useful for moving copies of the elements to another location in the DOM.ExampleYou can try to run the following code to learn how to clone an element using jQuery:Live Demo           jQuery clone() method                              $(document).ready(function() {             $("div").click(function () {                $(this).clone().insertAfter(this);             });          });                              .div {              margin:10px;              padding:12px;              border:2px solid #666;              width:60px;          }                             Click on any square below to see the result:                                          

Delete Rows with Duplicate and Similar Content in MySQL

AmitDiwan
Updated on 10-Dec-2019 07:29:09

106 Views

Let us first create a table −mysql> create table DemoTable1468    -> (    -> Id int,    -> Name varchar(20),    -> Age int    -> ); Query OK, 0 rows affected (1.21 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1468 values(100, 'Chris', 23); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable1468 values(101, 'Bob', 25); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable1468 values(102, 'David', 30); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable1468 values(100, 'Chris', 23); Query OK, 1 row affected (0.35 sec) mysql> ... Read More

Get or Set Value in HybridDictionary with Specified Key in C#

AmitDiwan
Updated on 10-Dec-2019 07:28:29

159 Views

To get or set the value in HybridDictionary with specified key, the code is as follows −Example Live Demousing System; using System.Collections.Specialized; public class Demo {    public static void Main() {       HybridDictionary myDict = new HybridDictionary();       myDict.Add("1", "Tablet");       myDict.Add("2", "Desktop");       myDict.Add("3", "Speakers");       myDict.Add("4", "Laptop");       myDict.Add("5", "Notebook");       myDict.Add("6", "Ultrabook");       myDict.Add("7", "HDD");       myDict.Add("8", "SDD");       Console.WriteLine("Value at key 5 = "+myDict["5"]);    } }OutputThis will produce the following output −Value at key 5 ... Read More

Duplicate a Div using jQuery

David Meador
Updated on 10-Dec-2019 07:27:38

3K+ Views

To duplicate a div in jQuery, use the jQuery clone() method.ExampleYou can try to run the following code to learn how to duplicate a div using jQuery:Live Demo $(document).ready(function(){    $("button").click(function(){       $("div").clone().appendTo("body");    }); }); This is a text Clone div and append

jQuery Clone Method Explained

David Meador
Updated on 10-Dec-2019 07:26:02

216 Views

To clone an element using jQuery, use the jQuery.clone() method. The clone() method clones matched DOM Elements and select the clones.This is useful for moving copies of the elements to another location in the DOM.ExampleYou can try to run the following code to learn how to work with jQuery.clone() method in jQuery:Live Demo           jQuery clone() method                              $(document).ready(function() {             $("div").click(function () {                $(this).clone().insertAfter(this);             });          });                              .div {              margin:15px;              padding:15px;              border:4px solid #666;              width:90px;          }                             Click on any square below to see the result:                                  

Advertisements