AmitDiwan has Published 11365 Articles

MySQL to perform DateTime comparison and find the difference between dates in different columns

AmitDiwan

AmitDiwan

Updated on 22-Aug-2019 08:34:53

202 Views

For this, use DATEDIFF() function. Let us first create a table −mysql> create table DemoTable(DOB datetime, CurrentDate datetime); Query OK, 0 rows affected (0.59 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('1995-01-21', CURDATE()); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable ... Read More

HTML DOM Input Password pattern property

AmitDiwan

AmitDiwan

Updated on 22-Aug-2019 08:28:31

323 Views

The HTML DOM Input Password pattern property is used for setting or returning the pattern attribute of an input password field. It checks the password against a regular expression specified by the pattern property.SyntaxFollowing is the syntax forSetting the pattern property −passwordObject.pattern = regexpHere, regexp is a regular expression against which ... Read More

How to sort by arbitrary keywords in MySQL?

AmitDiwan

AmitDiwan

Updated on 22-Aug-2019 08:26:29

145 Views

For this, use the ORDER BY FIELD() ASC. Let us first create a table −mysql> create table DemoTable(Title varchar(100)); Query OK, 0 rows affected (0.56 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('Java'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable ... Read More

MySQL query to retrieve only the column values with special characters?

AmitDiwan

AmitDiwan

Updated on 22-Aug-2019 08:20:11

1K+ Views

For this, use REGEXP. Let us first create a table −mysql> create table DemoTable(SubjectCode varchar(100)); Query OK, 0 rows affected (0.89 sec)Insert some records in the table using insert command. The records consists of text, numbers and special characters −mysql> insert into DemoTable values('Java899@22'); Query OK, 1 row affected (0.19 ... Read More

HTML DOM Input Password object

AmitDiwan

AmitDiwan

Updated on 22-Aug-2019 08:17:52

187 Views

The HTML DOM Input Password object is associated with the element with type “password”. We can create and access an input element with type password using the createElement() and getElementById() methods respectively.PropertiesFollowing are the properties for the password object −Sr.NoProperty & Description1autocompleteTo set or return the autocomplete attribute value ... Read More

How to list temporary table columns in MySQL?

AmitDiwan

AmitDiwan

Updated on 22-Aug-2019 08:12:05

561 Views

To list temporary table columns in MySQL, let us first create a temporary table.Here’s an example. We have created a temporary table with some columns that includes the details of a student −mysql> CREATE TEMPORARY TABLE DemoTable745 (    StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    StudentName varchar(100),   ... Read More

How to retrieve a value with MySQL count() having maximum upvote value?

AmitDiwan

AmitDiwan

Updated on 22-Aug-2019 08:10:27

76 Views

Let’s say we have some columns in the table, one for image path and another for the upvotes. However, the first column is the auto increment Id as shown below −mysql> create table DemoTable(    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, ImagePath varchar(100), UpvoteValue int ); Query OK, 0 ... Read More

Can we replace all the digits of column values to zero except the first digit?

AmitDiwan

AmitDiwan

Updated on 22-Aug-2019 08:09:32

67 Views

Yes, we can replace all the digits of column values to zero except the first digit. Let us first see an example and create a table −mysql> create table DemoTable744 (Number varchar(100)); Query OK, 0 rows affected (0.47 sec)Insert some records in the table using insert command −mysql> insert into ... Read More

MySQL query to keep only first 2 characters in column value and delete rest of the characters?

AmitDiwan

AmitDiwan

Updated on 22-Aug-2019 08:07:48

957 Views

To keep only first two characters and delete rest of the characters, use SUBSTRING().Let us first create a table −mysql> create table DemoTable743 (SubjectName varchar(100)); Query OK, 0 rows affected (0.54 sec)Insert some records in the table using insert command −mysql> insert into DemoTable743 values('MySQL'); Query OK, 1 row affected ... Read More

Find the records with % character in a LIKE query with MySQL

AmitDiwan

AmitDiwan

Updated on 22-Aug-2019 08:06:08

174 Views

Let us first create a table −mysql> create table DemoTable742 (Value varchar(100)); Query OK, 0 rows affected (2.91 sec)Insert some records in the table using insert command −mysql> insert into DemoTable742 values('632535MIT'); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable742 values('US%UK'); Query OK, 1 row affected (0.13 ... Read More

Advertisements