Chandu yadav has Published 1163 Articles

Using find() to search for nested keys in MongoDB?

Chandu yadav

Chandu yadav

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

670 Views

For find() to search for nested keys in MongoDB, you can use dot(.) notation. Following is the syntaxdb.yourCollectionName.find({"yourOuterFieldName.yourInnerFieldName":"yourValue"}).pretty();Let us first create a collection with documents:>db.searchForNestedKeysDemo.insertOne({"ClientName":"Larry", "ClientAge":28, "ClientExtra Details":{"isEducated":true, "CountryName":"US"}}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ca20e8b66324ffac2a7dc64") } >db.searchForNestedKeysDemo.insertOne({"ClientName":"Chris", "ClientAge":29, "ClientExtra Details":{"isEducated":false, "CountryName":"UK"}}); {    "acknowledged" : true,   ... Read More

Is there a way to convert Integer field into Varchar without losing data in MySQL?

Chandu yadav

Chandu yadav

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

987 Views

You can use ALTER command to convert Integer into Varchar. Let us first create a tablemysql> create table DemoTable (    UserId int,    UserFirstName varchar(20),    UserLastName varchar(20),    UserAge int ); Query OK, 0 rows affected (0.73 sec)Now check the description of table using DESC command:mysql> desc DemoTable;This ... Read More

How to Drop MySQL Table using Java?

Chandu yadav

Chandu yadav

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

208 Views

Let us first create a table in a database. The query to create a table is as followsmysql> create table customerDetails    -> (    -> CustomerId int,    -> CustomerName varchar(30)    -> ); Query OK, 0 rows affected (0.56 sec)Now display all tables from the database in order ... Read More

MySQL appears to DROP USER but user still exists in MySQL.users table?

Chandu yadav

Chandu yadav

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

114 Views

First check all the user and host from MySQL.user table with the help of select statement as shown belowmysql> select user, host from MySQL.user;The following is the output+------------------+-----------+ | user             | host      | +------------------+-----------+ | Bob             ... Read More

8086 program to divide a 16 bit number by an 8 bit number

Chandu yadav

Chandu yadav

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

11K+ Views

In this program we will see how to divide 16-bit number by an 8-bit number.Problem StatementWrite 8086 Assembly language program to divide 16-bit number stored in memory location offset 501. Divide it with 8-bit number stored in 500H. Also store result at memory offset 600.Discussiont8086 has DIV instruction to perform ... Read More

What is LabelValue class in JavaTuples?

Chandu yadav

Chandu yadav

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

87 Views

A LabelValue class is a Tuple of 2 elements with label as the first position, whereas value as the second. It is in the JavaTuples library. The LabelValue Tuple class is Typesafe, Immutable, Iterable, Serializable, etc.The following is the declaration of the LabelValue class;public final class LabelValue extends Tuple implements IValueLabel, ... Read More

How do I find all documents with a field that is NaN in MongoDB?

Chandu yadav

Chandu yadav

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

764 Views

To find all documents with a field that is NAN in MongoDB, use the following syntaxdb.yourCollectionName.find( { yourFieldName: NaN })Let us first create a collection with documents> db.nanDemo.insertOne({"Score":0/0}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ca251a26304881c5ce84b8a") } > db.nanDemo.insertOne({"Score":10/5}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ca2520e6304881c5ce84b8b") } ... Read More

How to handle error object in JSP using JSTL tags?

Chandu yadav

Chandu yadav

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

465 Views

You can make use of JSTL tags to write an error page ShowError.jsp with better structure and more information −           Show Error Page               Opps...                     ... Read More

MySQL query to calculate the average of values in a row?

Chandu yadav

Chandu yadav

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

311 Views

To calculate the average of values in a row in MySQL, use the following syntaxSELECT (yourTableName.yourColumnName1+yourTableName.yourColumnName2+yourTableName.yourColumnName3+, ..........N)/numberOfColumns AS anyAliasName FROM yourTableName;To understand the above syntax, let us create a table. The query to create a table is as followsmysql> create table calculateAverageDemo    -> (    -> x int,   ... Read More

How to find and modify a value in a nested array?

Chandu yadav

Chandu yadav

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

175 Views

To find and modify a value in a nested array, you can use update command. Let us first create a collection with documents> db.findAndModifyAValueInNestedArrayDemo.insertOne( { "CompanyName" : "Amazon", "DeveloperDetails" : [ { "ProjectName" : "Online Book Store", "TeamSize" : "5" }, { "ProjectName" : "Library Management System", "TeamSize" : "7" ... Read More

Advertisements