Use MongoDB $pull to Delete Documents Within an Array

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

252 Views

You need to use update command along with $pull operator to delete documents within an array. Let us create a collection with documents. Following is the query> db.deleteDocumentsDemo.insertOne( ... { ...    "_id":100, ...    "StudentsDetails" : [ ...       { ...          "StudentId" : 1, ...          "StudentName" : "John" ...       }, ...       { ...          "StudentId" : 2, ...          "StudentName" : "Carol" ...       }, ...       { ...         ... Read More

Generate a Random String in Java

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

1K+ Views

Let us first declare a string array and initialize −String[] strArr = { "P", "Q", "R", "S", "T", "U", "V", "W" };Now, create a Random object −Random rand = new Random();Generate random string −int res = rand.nextInt(strArr.length);Example Live Demoimport java.util.Random; public class Demo {    public static void main(String[] args) {       String[] strArr = { "P", "Q", "R", "S", "T", "U", "V", "W" };       Random rand = new Random();       int res = rand.nextInt(strArr.length);       System.out.println("Displaying a random string = " + strArr[res]);    } }OutputDisplaying a random string = RLet ... Read More

Modulus of Negative Numbers in C

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

1K+ Views

Here we will see what will be the result if we use negative numbers to get the modulus. Let us see the following programs and their outputs to get the idea.Example#include int main() {    int a = 7, b = -10, c = 2;    printf("Result: %d", a % b / c); }OutputResult: 3Here the precedence of % and / are same. So % is working at first, so a % b is generating 7, now after dividing it by c, it is generating 3. Here for a % b, the sign of left operand is appended to the ... Read More

Set MySQL Primary Keys Auto Increment to Unlimited

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

564 Views

You can use BIGINT but this is not unlimited but you can use large number of primary keys auto increment using it. The syntax is as follows −yourColumnName BIGINT NOT NULL AUTO_INCREMENT;To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table LargeAutoIncrement -> ( -> Id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY -> ); Query OK, 0 rows affected (0.78 sec)Now in this table you can store large number like 9223372036854775807 i.e. for primary key auto increment.Let us insert ... Read More

Difference Between CALL and JUMP Instructions in 8085 Microprocessor

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

4K+ Views

The main differences between a JMP instruction and a CALL instruction is as follows –If a JMP instruction is executed, we jump to the destination location, and the execution carries on from there, without bothering to come back later to the instruction after the JMP. On the other hand, if a CALL instruction is executed, we jump to the subroutine, and the execution carries on from there till the RET instruction is executed in the subroutine, and then we come back to the instruction after the CALL in the main program.The address of the next instruction after the CALL instruction ... Read More

Use AND Conjunctive Operators in Android SQLite

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

160 Views

Before getting into example, we should know what sqlite data base in android is. SQLite is an open source SQL database that stores data to a text file on a device. Android comes in with built in SQLite database implementation. SQLite supports all the relational database features. In order to access this database, you don't need to establish any kind of connections for it like JDBC, ODBC etc.This example demonstrate about How to use AND Conjunctive Operators in Android sqlite.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details ... Read More

Use BLOB Data Type in Android SQLite

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

1K+ Views

Before getting into example, we should know what sqlite data base in android is. SQLite is an open source SQL database that stores data to a text file on a device. Android comes in with built in SQLite database implementation. SQLite supports all the relational database features. In order to access this database, you don't need to establish any kind of connections for it like JDBC, ODBC etc.This example demonstrate about How to use blob data type in Android sqliteStep 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details ... Read More

MySQL SELECT Statement DISTINCT for Multiple Columns

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

621 Views

To understand the MySQL select statement DISTINCT for multiple columns, let us see an example and create a table. The query to create a table is as followsmysql> create table selectDistinctDemo    -> (    -> InstructorId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> StudentId int,    -> TechnicalSubject varchar(100)    -> ); Query OK, 0 rows affected (0.50 sec)Insert some records in the table using insert command. The query is as followsmysql> insert into selectDistinctDemo(StudentId, TechnicalSubject) values(121, 'Java'); Query OK, 1 row affected (0.15 sec) mysql> insert into selectDistinctDemo(StudentId, TechnicalSubject) values(121, 'MongoDB'); Query OK, 1 row affected (0.16 ... Read More

Use of c:redirect Tag in JSP

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

432 Views

The tag redirects the browser to an alternate URL by facilitating automatic URL rewriting, it supports context-relative URLs, and it also supports the tag.AttributeThe tag has the following attributes −AttributeDescriptionRequiredDefaulturlURL to redirect the user's browser toYesNonecontext/ followed by the name of a local web applicationNoCurrent applicationExampleIf you need to pass parameters to a tag, use the tag to create the URL first as shown below − Tag Example The above code will redirect the request to http://www.photofuntoos.com - Try it yourself.

LocalDate Range Method in Java

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

462 Views

The range of values for a ChronoField can be obtained using the range() method in the LocalDate class in Java. This method requires a single parameter i.e. the ChronoField for which the range of values is required and it returns the range of values.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; import java.time.temporal.ChronoField; import java.time.temporal.ValueRange; public class Main { public static void main(String[] args) { LocalDate ld = LocalDate.parse("2019-02-15"); System.out.println("The LocalDate is: " + ld); ... Read More

Advertisements