Nishtha Thakur has Published 498 Articles

How to implement MongoDB $or query?

Nishtha Thakur

Nishtha Thakur

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

166 Views

The syntax is as follows for the $or query in MongoDB −db.yourCollectionName.find({ $or : [ { "yourFieldName" : "yourValue1" }, {"yourFieldName":"yourValue2"}, ...........N ] } ).pretty();To understand the concept, let us create a collection with the document. The query to create a collection with a document is as follows −> db.orDemo.insertOne({"UserName":"Larry", ... Read More

unordered_multimap size() function in C++ STL

Nishtha Thakur

Nishtha Thakur

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

104 Views

unordered_multimap size() function in C++ STL returns the number of elements in the unordered map.AlgorithmBegin    Declare an empty map container m.    Performing reserve function to restrict the most appropriate    bucket_count of the map container.    Insert values in the map container.    Print the size of the ... Read More

How to use total_changes()in Android sqlite?

Nishtha Thakur

Nishtha Thakur

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

124 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 ... Read More

vector insert() function in C++ STL

Nishtha Thakur

Nishtha Thakur

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

793 Views

vector insert() function in C++ STL helps to increase the size of a container by inserting the new elements before the elements at the specified position.It is a predefined function in C++ STL.We can insert values with three types of syntaxes1. Insert values by mentioning only the position and value:vector_name.insert(pos, ... Read More

How to return static strings in MySQL?

Nishtha Thakur

Nishtha Thakur

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

1K+ Views

In order to return static strings in MySQL, you can use UNION. Following is the syntax −select 'yourStringValue1' as yourAliasName UNION select 'yourStringValue2' as yourAliasName;Let us implement the above syntax to return static strings in MySQL. Following is the query −mysql> select 'HELLO' as staticStringsResult    -> UNION    -> ... Read More

How to use OR Conjunctive Operators in Android sqlite?

Nishtha Thakur

Nishtha Thakur

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

140 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 ... Read More

How to stop MongoDB in a single command?

Nishtha Thakur

Nishtha Thakur

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

628 Views

In order to stop MongoDB in a single command, use the following syntax −mongo --eval "db.getSiblingDB('admin').shutdownServer()"Let us implement the above syntax in order to stop MongoDB in one command.First, use the shortcut key −Ctrl + C;The query is as follows −C:\Program Files\MongoDB\Server\4.0\bin>mongo --eval "db.getSiblingDB('admin').shutdownServer()"The following is the output − displaying ... Read More

What if I forgot to set Auto Increment? Can I set it later in MySQL?

Nishtha Thakur

Nishtha Thakur

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

148 Views

Yes, you can set Auto Increment later with ALTER table. Let us first create a table. Here, as you can see, we haven’t set Auto Increment −mysql> create table forgetToSetAutoIncrementDemo    -> (    -> StudentId int,    -> StudentName varchar(30)    -> ); Query OK, 0 rows affected (1.17 ... Read More

How to form a composite key to be unique in MySQL?

Nishtha Thakur

Nishtha Thakur

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

2K+ Views

To form a composite key to be unique, you need to use ADD UNIQUE command. Following is the syntax −alter table yourTableName add unique yourUniqueName( yourColumnName1, yourColumnName2, .......N);Let us first create a table. Following is the query −mysql> create table makeCompositeKeyDemo    -> (    -> Id int NOT NULL ... Read More

Identify last document from MongoDB find() result set?

Nishtha Thakur

Nishtha Thakur

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

231 Views

To identify the last document from MongoDB find() result set, you can use sort() in descending order. The syntax is as follows −db.yourCollectionName.find().sort( { _id : -1 } ).limit(1).pretty();To understand the above syntax, let us create a collection with the document. The query to create a collection with a document ... Read More

Advertisements