Ankith Reddy has Published 996 Articles

How to convert from string to date data type in MongoDB?

Ankith Reddy

Ankith Reddy

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

804 Views

To convert from String to date data type, you need to write some script. Let us first create a collection with documents>db.stringToDateDataTypeDemo.insertOne({"CustomerName":"Carol", "ShippingDate":"2019- 01-21"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ca2071d66324ffac2a7dc60") } >db.stringToDateDataTypeDemo.insertOne({"CustomerName":"Bob", "ShippingDate":"2019- 02-24"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ca2073566324ffac2a7dc61") } >db.stringToDateDataTypeDemo.insertOne({"CustomerName":"Chris", "ShippingDate":"2019- 04-01"}); ... Read More

MySQL temporary variable assignment?

Ankith Reddy

Ankith Reddy

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

3K+ Views

You can use SET command for temporary variable assignment.The syntax is as followsSET @anyVariableName=(SELECT yourColumnName FROM yourTableName WHERE yourCondition);To understand the above syntax, let us create a table. The query to create a table is as followsmysql> create table tempVariableAssignment    -> (    -> Id int NOT NULL AUTO_INCREMENT ... Read More

8086 program to multiply two 8-bit numbers

Ankith Reddy

Ankith Reddy

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

12K+ Views

In this program we will see how to multiply two 8-bit numbers.Problem StatementWrite 8086 Assembly language program to multiply two 8-bit numbers stored in memory address offset 500 and 501.DiscussiontIn 8086 there is MUL instruction. So the task is too simple. Here we are taking the numbers from memory and ... Read More

Iterate through Decade Tuple in Java

Ankith Reddy

Ankith Reddy

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

188 Views

To iterate through Decade Tuple, work it like any other collection in Java i.e. using a for loop, iterate and display the elements. Let us first see what we need to work with JavaTuples. To work with Decade class in JavaTuples, you need to import the following packageimport org.javatuples.Decade;Note: Download ... Read More

How can I use $elemMatch on first level array in MongoDB?

Ankith Reddy

Ankith Reddy

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

263 Views

You can use $in operator instead of $elemMatch on first level array. The syntax is as followsdb.yourCollectionName.find({yourFieldName:{$in:["yourValue"]}}).pretty();Let us first create a collection with documents>db.firstLevelArrayDemo.insertOne({"StudentName":"Chris", "StudentTechnicalSkills":["Mongo DB", "MySQL", "SQL Server"]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ca2360f66324ffac2a7dc71") } >db.firstLevelArrayDemo.insertOne({"StudentName":"Robert", "StudentTechnicalSkills":["C", "J ava", "C++"]}); {    "acknowledged" : true,   ... Read More

What is an exception Object in JSP? What type of exceptions can occur in a JSP page?

Ankith Reddy

Ankith Reddy

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

218 Views

The exception object is a wrapper containing the exception thrown from the previous page. It is typically used to generate an appropriate response to the error condition.When you are writing a JSP code, you might make coding errors which can occur at any part of the code. There may occur ... Read More

MySQL query to get max id from varchar type and the values in numeric?

Ankith Reddy

Ankith Reddy

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

362 Views

Use CAST() in MAX() to get max id from varchar type and values in numeric. Let us first create a table. Here, we have a column with varchar type −mysql> create table DemoTable (    UserMarks varchar(20) ); Query OK, 0 rows affected (0.77 sec)Insert some records in the table ... Read More

How to avoid null result of “SELECT max(rank) FROM test” for an empty table?

Ankith Reddy

Ankith Reddy

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

3K+ Views

You can use COALESCE() along with aggregate function MAX() for this.The syntax is as followsSELECT COALESCE(MAX(`yourColumnName`), 0) FROM yourTableName;To understand the above syntax, let us create a table. The query to create a table is as followsmysql> create table avoidNullDemo    -> (    -> `rank` int    -> ); ... Read More

The get() method of Java AbstractSequentialList class

Ankith Reddy

Ankith Reddy

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

105 Views

The get() method of the AbstractSequentialList class is used to display the element at the specified position in this list.The syntax is as followspublic E get(int index)Here, index is the location from where you want to get the element.To work with the AbstractSequentialList class in Java, you need to import ... Read More

How to query on top N rows in MongoDB?

Ankith Reddy

Ankith Reddy

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

3K+ Views

To query on top N rows in MongoDB, you can use aggregate framework. Let us create a collection with documents> db.topNRowsDemo.insertOne({"StudentName":"Larry", "Score":78}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ca26eee6304881c5ce84b91") } > db.topNRowsDemo.insertOne({"StudentName":"Chris", "Score":45}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ca26ef66304881c5ce84b92") } > db.topNRowsDemo.insertOne({"StudentName":"Mike", "Score":65}); {   ... Read More

Advertisements