Nishtha Thakur

Nishtha Thakur

398 Articles Published

Articles by Nishtha Thakur

Page 34 of 40

MongoDB Query to select records having a given key?

Nishtha Thakur
Nishtha Thakur
Updated on 30-Jul-2019 226 Views

To select records having a given key, you can use $exists operator. The syntax is as follows −db.yourCollectionName.find( { yourFieldName: { $exists : 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.selectRecordsHavingKeyDemo.insertOne({"StudentName":"John", "StudentAge":21, "StudentMathMarks":78}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c8b7be780f10143d8431e0f") } > db.selectRecordsHavingKeyDemo.insertOne({"StudentName":"Carol", "StudentMathMarks":89}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c8b7bfc80f10143d8431e10") } > db.selectRecordsHavingKeyDemo.insertOne({"StudentName":"Sam", "StudentAge":26, "StudentMathMarks":89}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c8b7c1280f10143d8431e11") } > db.selectRecordsHavingKeyDemo.insertOne({"StudentName":"Sam", "StudentMathMarks":98}); {    "acknowledged" : true, ...

Read More

How to get last row in Android sqlite?

Nishtha Thakur
Nishtha Thakur
Updated on 30-Jul-2019 837 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 get last row in Android sqliteStep 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to ...

Read More

How to convert a std::string to const char* or char* in C++?

Nishtha Thakur
Nishtha Thakur
Updated on 30-Jul-2019 2K+ Views

In this section, we will see how to convert C++ string (std::string) to const char* or char*. These formats are C style strings. We have a function called c_str(). This will help us to do the task. It returns a pointer to an array that contains a null-terminated sequence of characters (i.e., a C-string) representing the current value of the string object.Following is the declaration for std::string::c_str.const char* c_str() const;This function returns a pointer to an array that contains a null-terminated sequence of characters (i.e., a C-string) representing the current value of the string object. If an exception is thrown, ...

Read More

Is there any need of “long” data type in C and C++?

Nishtha Thakur
Nishtha Thakur
Updated on 30-Jul-2019 215 Views

In C or C++, there are four different datatypes, that are used for integer type data. These four datatypes are short, int, long and long long. Each of these datatypes takes different memory spaces. The size varies in different architecture and different operating systems. Sometimes int takes 4-bytes or sometimes it takes 2-bytes. This also happen for the compilers. So we can use cross compilers.The cross compilers are basically a compiler, which is capable of compiling for a platform other than current platform.So if we want to compile the following code in 32bit system, and 64-bit system, it will generate ...

Read More

MySQL query to remove Null Records in a column?

Nishtha Thakur
Nishtha Thakur
Updated on 30-Jul-2019 2K+ Views

To remove NULL records in a column, you can use delete command. Following is the syntax −delete from yourTableName where yourColumnName IS NULL;Let us first create a table −mysql> create table removeNullRecordsDemo    -> (    -> Name varchar(100)    -> ); Query OK, 0 rows affected (0.50 sec)Following is the query to insert records in the table using insert command −mysql> insert into removeNullRecordsDemo values('John'); Query OK, 1 row affected (0.14 sec) mysql> insert into removeNullRecordsDemo values(null); Query OK, 1 row affected (0.15 sec) mysql> insert into removeNullRecordsDemo values('Larry'); Query OK, 1 row affected (0.19 sec) ...

Read More

C++ Program to Create a Random Graph Using Random Edge Generation

Nishtha Thakur
Nishtha Thakur
Updated on 30-Jul-2019 1K+ Views

In this program a random graph is generated for random vertices and edges. The time complexity of this program is O(v * e). Where v is the number of vertices and e is the number of edges.AlgorithmBegin    Develop a function GenRandomGraphs(), with ‘e’ as the    number of edges and ‘v’ as the number of vertexes, in the argument list.       Assign random values to the number of vertex and edges of the graph,    using rand() function.       Print the connections of each vertex, irrespective of the       direction.       ...

Read More

How to remove data from hashset in Android?

Nishtha Thakur
Nishtha Thakur
Updated on 30-Jul-2019 248 Views

This example demonstrates about How to remove data from HashSet in AndroidStep 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.                                       In the above code, we have taken the name and record number as Edit text, when user clicks on save button it will store the data into ArrayList. Click on delete button ...

Read More

How to strip all spaces from a column in MySQL?

Nishtha Thakur
Nishtha Thakur
Updated on 30-Jul-2019 1K+ Views

To strip all spaces from a column in MySQL, you can use REPLACE() function. Following is the syntax −update yourTableName set yourColumnName=REPLACE(yourColumnName, ' ', '' );Let us first create a table −mysql> create table stripAllSpacesDemo    -> (    -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> Name varchar(100)    -> ); Query OK, 0 rows affected (0.56 sec)Following is the query to insert records in the table using insert command −mysql> insert into stripAllSpacesDemo(Name) values('Jo h n'); Query OK, 1 row affected (0.19 sec) mysql> insert into stripAllSpacesDemo(Name) values(' Joh n'); Query OK, 1 row affected (0.16 ...

Read More

How to use distinct and count in Android sqlite?

Nishtha Thakur
Nishtha Thakur
Updated on 30-Jul-2019 740 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 distinct and count t in Android sqliteStep 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required ...

Read More

How to arrange data in s specific order in MySQL?

Nishtha Thakur
Nishtha Thakur
Updated on 30-Jul-2019 173 Views

Use ORDER BY IF() to arrange data in a specific order. Following is the syntax −select *from yourTableName ORDER BY IF(yourColumnName=yourValue1 OR yourColumnName=yourValue2 OR yourColumnName=yourValue3, yourColumnName, ~yourColumnName) ASC;Let us first create a table −mysql> create table arrangeDataInSpecificOrder    -> (    -> StudentId int,    -> StudentName varchar(20)    -> ); Query OK, 0 rows affected (0.64 sec)Following is the query to insert some records in the table using insert command −mysql> insert into arrangeDataInSpecificOrder values(10, 'Larry'); Query OK, 1 row affected (0.12 sec) mysql> insert into arrangeDataInSpecificOrder values(15, 'Mike'); Query OK, 1 row affected (0.09 sec) mysql> insert into ...

Read More
Showing 331–340 of 398 articles
« Prev 1 32 33 34 35 36 40 Next »
Advertisements