AmitDiwan has Published 10740 Articles

Set multiple values for custom columns in MySQL?

AmitDiwan

AmitDiwan

Updated on 31-Dec-2019 08:14:56

556 Views

For this, you can use UNION ALL. Let us first create a table −mysql> create table DemoTable1987    (    UserValue int    ); Query OK, 0 rows affected (2.90 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1987 values(4); Query OK, 1 row affected (0.22 ... Read More

Only display specified values inside the IN clause with MySQL?

AmitDiwan

AmitDiwan

Updated on 31-Dec-2019 08:13:56

135 Views

For this, you can use IN() along with ORDER BY clause. Let us first create a table −mysql> create table DemoTable1986    (    Number int    ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1986 values(50); Query OK, ... Read More

jQuery index() with examples

AmitDiwan

AmitDiwan

Updated on 31-Dec-2019 08:13:05

305 Views

The index() method in jQuery is used to return the index position of specified elements relative to other specified elements.SyntaxThe syntax is as follows −$(selector).index()ExampleLet us now see an example to implement the jQuery index() method − Live Demo    $(document).ready(function(){       $("li").click(function(){       ... Read More

Date format to convert dates like Jan 2017, May 2018 to complete date in MySQL

AmitDiwan

AmitDiwan

Updated on 31-Dec-2019 08:11:30

217 Views

For this, use STR_TO_DATE() along with DATE_FORMAT(). Let us first create a table −mysql> create table DemoTable1985    (    DueDate varchar(20)    ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1985 values('Jan 2017'); Query OK, 1 row affected ... Read More

jQuery toggleClass() with Examples

AmitDiwan

AmitDiwan

Updated on 31-Dec-2019 08:10:40

335 Views

The toggleClass() method in jQuery is used to toggle between adding or removing one or more classes from selected elements.SyntaxThe syntax is as follows −$(selector).toggleClass(classname, func(index, currentclass), switch)Above, class name specifies one or more class names to add or remove, whereas func is a function that returns one or more ... Read More

How to change the date in a table with date records with MySQL?

AmitDiwan

AmitDiwan

Updated on 31-Dec-2019 08:09:27

729 Views

Let’s say you need to change the date and add years. For this, use UPDATE command along with DATE_ADD(). Let us first create a table −mysql> create table DemoTable1984    (    ShippingDate date    ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert ... Read More

How to insert a row with a timestamp “X days ago” in MySQL?

AmitDiwan

AmitDiwan

Updated on 31-Dec-2019 08:08:24

315 Views

To insert a row like this use the following syntax, wherein we are using CURRENT_TIMESTAMP −insert into yourTableName values(CURRENT_TIMESTAMP - INTERVAL ABS(RAND() * 100) DAY);To understand the above syntax, let us create a table −mysql> create table DemoTable1983    (    DueDate timestamp    ); Query OK, 0 rows affected ... Read More

jQuery removeData() with Examples

AmitDiwan

AmitDiwan

Updated on 31-Dec-2019 08:07:33

166 Views

The removeData() method in jQuery is used to remove the data set with the data() method.SyntaxThe syntax is as follows −$(selector).removeData(name)Above, the name parameter is used to specify the name of the data to remove.ExampleLet us now see an example to implement the jQuery removeData() method − Live Demo ... Read More

MySQL - changing table engine from innoDB to MyISAM?

AmitDiwan

AmitDiwan

Updated on 31-Dec-2019 08:06:19

375 Views

Let us first create a table −mysql> create table DemoTable1982    (    StudentId int    ,    StudentName varchar(20),    StudentAge int    ); Query OK, 0 rows affected (0.00 sec)Let us check the table engine type -mysql> show create table DemoTable1982;This will produce the following output −+---------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | ... Read More

MySQL query to calculate sum from 5 tables with a similar column named “UP”?

AmitDiwan

AmitDiwan

Updated on 31-Dec-2019 08:02:41

530 Views

For this, use UNION ALL along with SUM(). Let us create 5 tables −mysql> create table DemoTable1977    (    UP int    ); Query OK, 0 rows affected (0.00 sec) mysql> insert into DemoTable1977 values(10); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1977 values(20); Query OK, ... Read More

Advertisements