Nishtha Thakur has Published 495 Articles

How to arrange data in s specific order in MySQL?

Nishtha Thakur

Nishtha Thakur

Updated on 30-Jul-2019 22:30:25

163 Views

Use ORDER BY IF() to arrange data in a specific order. Following is the syntax −select *from yourTableName ORDER BY IF(yourColumnName=yourValue1 OR yourColumnName=yourValue2 OR yourColumnName=yourValue3, yourColumnName, ~yourColumnName) ASC;Let us first create a table −mysql> create table arrangeDataInSpecificOrder    -> (    -> StudentId int,    -> StudentName varchar(20)    -> ... Read More

Clone a collection in MongoDB?

Nishtha Thakur

Nishtha Thakur

Updated on 30-Jul-2019 22:30:25

672 Views

To clone a collection in MongoDB, you can use the forEach() method. Let us first create a collection with a document.The query to create a collection with a document is as follows −> db.studentInformation.insertOne({"StudentName":"Chris"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c8bc15780f10143d8431e21") } > db.studentInformation.insertOne({"StudentName":"Robert"}); {    "acknowledged" : ... Read More

How to find if a column is auto_increment in MySQL?

Nishtha Thakur

Nishtha Thakur

Updated on 30-Jul-2019 22:30:25

1K+ Views

To find if a column is auto_increment in MySQL, you can use the following syntax −select COLUMN_NAME from information_schema.columns where TABLE_SCHEMA='yourDatabaseName' and TABLE_NAME='yourTableName' and EXTRA like '%auto_increment%';Let us first create a table. Here, ClientId is set AUTO_INCREMENT −mysql> create table autoIncrementTableDemo    -> (    -> ClientId int NOT NULL ... Read More

Convert UNIX timestamp into human readable format in MySQL?

Nishtha Thakur

Nishtha Thakur

Updated on 30-Jul-2019 22:30:25

1K+ Views

To convert UNIX timestamp into a human-readable format, use the FROM_UNIXTIME() method.Let us first create a table −mysql> create table timeConversionDemo    -> (    -> dateTimeConversion bigint    -> ); Query OK, 0 rows affected (0.45 sec)Following is the query to insert records in the table using insert command ... Read More

Resolve ‘multi update only works with $ operators’ in MongoDb?

Nishtha Thakur

Nishtha Thakur

Updated on 30-Jul-2019 22:30:25

864 Views

You can use $set operator for this. The syntax is as follows −db.yourCollectionName.update({ }, {'$set': "yourFieldName": "yourValue" }, false, true);To understand the above syntax, let us create a collection with the document. The query to create a collection with a document is as follows −> db.unconditionalUpdatesDemo.insertOne({"ClientName":"Larry", "ClientAge":24}); {    "acknowledged" ... Read More

MySQL query to display all the fields that contain a capital letter?

Nishtha Thakur

Nishtha Thakur

Updated on 30-Jul-2019 22:30:25

1K+ Views

To display all the fields that contain a capital letter, use the RLIKE that performs a pattern match of a string expression against a pattern.Let us first create a table −mysql> create table contains_capital_letterDemo    -> (    -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> Name varchar(100) ... Read More

How to select distinct value from one MySQL column only?

Nishtha Thakur

Nishtha Thakur

Updated on 30-Jul-2019 22:30:25

1K+ Views

To select distinct value from one column only, you can use aggregate function MAX() along with GROUP BY. Let us first create a table −mysql> create table distinctFromOneColumn    -> (    -> StudentId int,    -> StudentName varchar(100)    -> ); Query OK, 0 rows affected (0.77 sec)Following is ... Read More

C++ Program to Implement Queue

Nishtha Thakur

Nishtha Thakur

Updated on 30-Jul-2019 22:30:25

3K+ Views

QueueThe queue which is implemented as FIFO where insertions are done at one end (rear) and deletions are done from another end (front). The first element that entered is deleted first.Queue operations are −EnQueue (int data) − Insertion at rear endint DeQueue()− Deletion from front endThis is a C++ program ... Read More

How to compare timestamps in MySQL?

Nishtha Thakur

Nishtha Thakur

Updated on 30-Jul-2019 22:30:25

4K+ Views

To compare timestamps in MySQL, you can use DATE(). Let us first create a table−mysql> create table comparingTimestampDemo    -> (    -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> AdmissionDate timestamp    -> ); Query OK, 0 rows affected (0.54 sec)Following is the query to insert records ... Read More

Add10 minutes to MySQL datetime format?

Nishtha Thakur

Nishtha Thakur

Updated on 30-Jul-2019 22:30:25

415 Views

Use DATE_ADD() to add 10 minutes to datetime format. Following is the syntax −select date_add(yourColumnName ,interval 10 minute) from yourTableName;Let us first create a table −mysql> create table add10MinuteDemo    -> (    -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> DelayDatetime datetime    -> ); Query OK, ... Read More

Advertisements