Krantik Chavan has Published 278 Articles

Is it possible to divide records in both ascending and descending order in MySQL and display them alternatively?

Krantik Chavan

Krantik Chavan

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

115 Views

Yes, you can perform this in MySQL by first getting the middle value. Let us first create a table:mysql> create table DemoTable (    UserId int NOT NULL AUTO_INCREMENT PRIMARY KEY ); Query OK, 0 rows affected (0.65 sec)Following is the query to insert some records in the table using ... Read More

Period isNegative() method in Java

Krantik Chavan

Krantik Chavan

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

246 Views

It can be checked if the days, months and years in the Period are negative or not using the isNegative() method in the Period class in Java. This method requires no parameters. Also, it returns true if any of the days, months and years in the Period are negative and ... Read More

How to delete all the documents from a collection in MongoDB?

Krantik Chavan

Krantik Chavan

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

646 Views

If you want to delete all documents from the collection, you can use deleteMany(). Let us first create a collection and insert some documents to it:> db.deleteDocumentsDemo.insert({"Name":"Larry", "Age":23}); WriteResult({ "nInserted" : 1 }) > db.deleteDocumentsDemo.insert({"Name":"Mike", "Age":21}); WriteResult({ "nInserted" : 1 }) > db.deleteDocumentsDemo.insert({"Name":"Sam", "Age":24}); WriteResult({ "nInserted" : 1 })Now display ... Read More

How to retrieve documents from a collection in MongoDB?

Krantik Chavan

Krantik Chavan

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

1K+ Views

To retrieve documents from a collection in MongoDB, you need to use find() method. The syntax is as follows:db.yourCollectionName.find();The above syntax will return all the documents from a collection in MongoDB. To understand the above syntax, let us create a collection with documents. The query to create documents are as ... Read More

Retrieve only the queried element in an object array in MongoDB collection?

Krantik Chavan

Krantik Chavan

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

314 Views

You can use projection operator $elemMatch to filter in queried element in an object array in MongoDB collection. To retrieve only the queried element in an object array in MongoDB, let us first create a collection with documents object array.The query is as follows:> db.objectArray.insert({"Persons":[    {"PersonName":"Adam", "PersonSalary":25000}, {"PersonName":"Larry", "PersonSalary":27000 ... Read More

Update MongoDB field using value of another field?

Krantik Chavan

Krantik Chavan

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

2K+ Views

You can use aggregate function to update MongoDB field using the value of another field. Here, we will create two collections:namestudentInformation CollectionThe query to create first collection with documents is as follows:> db.name.insert({"FirstName":"John", "LastName":"Smith"}); WriteResult({ "nInserted" : 1 })Now you can display all documents from the collection with the help ... Read More

What is static import in Java?

Krantik Chavan

Krantik Chavan

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

718 Views

As import statement allows to use a class without its package qualification, static import allows to access the static members of a class without class qualifications. For Example, to access the static methods you need to call the using class name − Math.sqrt(169); But, using static import you ... Read More

Writing at the end of report without clearing current screen in SAP ABAP

Krantik Chavan

Krantik Chavan

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

162 Views

Yes, it is possible. You would require using MODIFY LINE

Advertisements