Ankith Reddy has Published 1070 Articles

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

Ankith Reddy

Ankith Reddy

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

158 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

131 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

259 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

68 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

8086 program to find sum of odd numbers in a given series

Ankith Reddy

Ankith Reddy

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

3K+ Views

In this program we will see how to add odd numbers in a given seriesProblem StatementWrite 8086 Assembly language program to add the odd numbers stored in a given series starts from memory offset 501. The size of the series is stored at memory offset 500.DiscussionTo do this task we ... Read More

How to query an Array[String] for a Regular Expression match?

Ankith Reddy

Ankith Reddy

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

151 Views

To query an array string for a regexp match, use the following syntaxdb.yourCollectionName.find( { yourFieldName: /yourStartingValue./ } ).pretty();Let us first create a collection with documents> db.queryArrayDemo.insertOne({"StudentFullName":["Carol Taylor", "Caroline Williams", "Claire Brown"]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ca2774c6304881c5ce84ba0") } > db.queryArrayDemo.insertOne({"StudentFullName":["John Smith", "Jace Doe", "Jabin Brown"]}); {   ... Read More

How to determine the current delimiter in MySQL?

Ankith Reddy

Ankith Reddy

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

480 Views

To determine current delimiter in MySQL, use the following syntax\sThe above syntax will let you know about the current delimiter. Let us implement the above syntax.The query is as followsmysql> \sThe following is the output-------------- C:\Program Files\MySQL\MySQL Server 8.0\bin\mysql.exe Ver 8.0.12 for Win64 on x86_64 (MySQL Community Server - GPL) ... Read More

How to ORDER BY last 2 character string in MySQL?

Ankith Reddy

Ankith Reddy

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

2K+ Views

You can use ORDER BY RIGHT() to ORDER BY last 2 character string.The syntax is as followsselect yourColumnName from yourTableName ORDER BY RIGHT(yourColumnName , 2);To understand the above syntax, let us create a table. The query to create a table is as followsmysql> create table OrderByLast2CharactersDemo    -> (   ... Read More

Advertisements