George John has Published 1081 Articles

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

344 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

1K+ 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

727 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

276 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

499 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

164 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

What are filters in JSP?

George John

George John

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

231 Views

Servlet and JSP Filters are Java classes that can be used in Servlet and JSP Programming for the following purposes To intercept requests from a client before they access a resource at the back end.To manipulate responses from the server before they are sent back to the client.There are various types ... Read More

IntStream flatMap() method in Java

George John

George John

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

842 Views

The flatMap() method of the IntStream class returns a stream consisting of the results of replacing each element of this stream with the contents of a mapped stream produced by applying the provided mapping function to each element.The syntax is as followsIntStream flatMap(IntFunction

Advertisements