Smita Kapse has Published 498 Articles

MongoDB Query for boolean field as “not true”

Smita Kapse

Smita Kapse

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

965 Views

You can use $ne(not equal) operator for this. The syntax is as follows −db.yourCollectionName.find({yourFieldName: {$ne: true}}).pretty();To understand the above syntax, let us create a collection with the document. The query to create a collection with a document is as follows −> db.queryForBooleanFieldsDemo.insertOne({"EmployeeName":"Larry", "EmployeeAge":24, "isOldEmployee":true}); {    "acknowledged" : true,   ... Read More

Padding the beginning of a MySQL INT field with zeroes?

Smita Kapse

Smita Kapse

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

446 Views

You can use LPAD() from MySQL to pad the beginning of a MySQL INT field with zeroes. Let us first create a table.mysql> create table paddingDemo    -> (    -> Number int    -> ); Query OK, 0 rows affected (0.49 sec)Following is the query to insert some records ... Read More

How to quickly reverse a string in C++?

Smita Kapse

Smita Kapse

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

357 Views

In this section, we will see how to reverse a string very quickly using C++. For reversing there is a built-in function in the algorithm library, called reverse(). This function takes the beginning and the ending pointer of a container, then reverse the elements.Input: A number string “Hello World” Output: ... Read More

How do I insert a NULL value in MySQL?

Smita Kapse

Smita Kapse

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

3K+ Views

To insert a NULL value, you can use UPDATE command. Following is the syntax −UPDATE yourTableName SET yourColumnName=NULL;Let us first create a table −mysql> create table insertNullValue    -> (    -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> ClientName varchar(100),    -> ClientCountryName varchar(20)    -> ); ... Read More

C++ Program to Find Transitive Closure of a Graph

Smita Kapse

Smita Kapse

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

515 Views

If a directed graph is given, determine if a vertex j is reachable from another vertex i for all vertex pairs (i, j) in the given graph. Reachable mean that there is a path from vertex i to j. This reachability matrix is called transitive closure of a graph. Warshall ... Read More

How to get current time from Network provider in android?

Smita Kapse

Smita Kapse

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

1K+ Views

This example demonstrate about How to get current time from Network provider in android.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.     ... Read More

How can I rename a collection in MongoDB?

Smita Kapse

Smita Kapse

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

780 Views

To rename a collection in MongoDB, you can use renameCollection() method. The syntax is as follows −db.yourOldCollectionName.renameCollection('yourNewCollectionName');To understand the above syntax, let us list all the collections from database sample. The query is as follows −> use sample; switched to db sample > show collections;The following is the output −copyThisCollectionToSampleDatabaseDemo ... Read More

String tokenisation function in C

Smita Kapse

Smita Kapse

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

6K+ Views

In this section, we will see how to tokenize strings in C. The C has library function for this. The C library function char *strtok(char *str, const char *delim) breaks string str into a series of tokens using the delimiter delim.Following is the declaration for strtok() function.char *strtok(char *str, const ... Read More

Select rows having more than 2 decimal places in MySQL?

Smita Kapse

Smita Kapse

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

1K+ Views

To select rows with more than 2 decimal places, use SUBSTR() function from MySQL. Let us first create a table −mysql> create table selectRows2DecimalPlacesDemo    -> (    -> Amount varchar(100)    -> ); Query OK, 0 rows affected (0.73 sec)Following is the query to insert records in the table ... Read More

What is the easiest way to convert int to string in C++

Smita Kapse

Smita Kapse

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

434 Views

In this section, we will see how to convert an integer to a string.The logic is very simple. Here we will use the sprintf() function. This function is used to print some value or line into a string, but not in the console. This is the only difference between printf() ... Read More

Advertisements