George John has Published 1167 Articles

How to query a key having space in its name with MongoDB?

George John

George John

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

2K+ Views

To query a key having space in its name, you can use dot(.) notation.Step 1: First, you need to create a set in which a key has space in its name. Following is the query:> myValues["Details"] = {} { } > myValues["Details"]["Student Name"]="John"; John > myValues["Details"]["StudentAge"]=26; 26Step 2: Now you ... Read More

LongStream filter() method in Java

George John

George John

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

122 Views

The filter() method in the LongStream class in Java returns a stream consisting of the elements of this stream that match the given predicate.The syntax is as followsLongStream filter(LongPredicate predicate)Here, the parameter predicate is a stateless predicate to apply to each element to determine if it should be included. The ... Read More

How to project specific fields from a document inside an array in Mongodb?

George John

George John

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

263 Views

To project specific fields from a document inside an array, you can use positional ($) operator.Let us first create a collection with documents> db.projectSpecificFieldDemo.insertOne(    ... {       ... "UniqueId": 101,       ... "StudentDetails" : [{"StudentName" : "Chris", "StudentCountryName ": "US"},          ... ... Read More

How to count null values in MySQL?

George John

George John

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

820 Views

To count null values in MySQL, you can use CASE statement. Let us first see an example and create a table −mysql> create table DemoTable (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    FirstName varchar(20) ); Query OK, 0 rows affected (0.77 sec)Insert some records in the table ... Read More

How to convert MySQL null to 0 using COALESCE() function?

George John

George John

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

588 Views

You can use the COALESCE() function to convert MySQL null to 0SELECT COALESCE(yourColumnName, 0) AS anyAliasName FROM yourTableName;Let us first create a table. The query to create a table is as followsmysql> create table convertNullToZeroDemo    -> (    -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> Name ... Read More

Get number of updated documents in MongoDB?

George John

George John

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

172 Views

To get number of updated documents in MongoDB, you need to use runCommand along with getlasterror.Let us first create a collection with documents> db.getNumberOfUpdatedDocumentsDemo.insertOne({"StudentName":"David"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ca28c1d6304881c5ce84bad") } > db.getNumberOfUpdatedDocumentsDemo.insertOne({"StudentName":"Chris"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ca28c226304881c5ce84bae") } > db.getNumberOfUpdatedDocumentsDemo.insertOne({"StudentName":"Robert"}); {   ... Read More

How to read form data using JSP via GET Method?

George John

George John

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

396 Views

Following is an example that passes two values using the HTML FORM and the submit button. We are going to use the same JSP main.jsp to handle this input.                    First Name:                 ... Read More

MySQL query to list all the items in a group in one record?

George John

George John

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

1K+ Views

You can use GROUP_CONCAT() function to list all the items in a group in one record. Let us first create a table −mysql> create table DemoTable (    ProductId int,    ProductName varchar(40),    ProductCategory varchar(40) ); Query OK, 0 rows affected (0.67 sec)Insert some records in the table using ... Read More

Stored procedure using variable in LIMIT expression?

George John

George John

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

83 Views

Let us firs create a tablemysql> create table LimitWithStoredProcedure    -> (    -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> Name varchar(10)    -> ); Query OK, 0 rows affected (0.47 sec)Insert some records in the table using insert command.The query is as followsmysql> insert into LimitWithStoredProcedure(Name) ... Read More

C Program to print hollow pyramid and diamond pattern

George John

George John

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

3K+ Views

Here we will see how to generate hollow pyramid and diamond patterns using C. We can generate solid Pyramid patterns very easily. To make it hollow, we have to add some few tricks.Hollow PyramidFor the pyramid at the first line it will print one star, and at the last line ... Read More

Advertisements