Smita Kapse has Published 558 Articles

Select rows having more than 2 decimal places in MySQL?

Smita Kapse

Smita Kapse

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

918 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

325 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

Calling virtual functions inside constructors in C++

Smita Kapse

Smita Kapse

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

195 Views

Virtual functions calling from a constructor or destructor is dangerous and should be avoided whenever possible as the virtual function we call is called from the Base class and not from the derived class.The reason is that in C++ Super-classes are constructed before derived classes. So, in the following example, ... Read More

How to delete all rows except some in MySQL?

Smita Kapse

Smita Kapse

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

5K+ Views

You can use NOT IN operator for the rows you do not want to delete. Following is the syntax −delete from yourTableName where yourColumnName NOT IN(‘yourValue1’, ‘yourValue2’, ‘yourValue3’, .........N);Let us first create a table −mysql> create table deleteAllRowsWithCondition    -> (    -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, ... Read More

How to use hex () in Android sqlite?

Smita Kapse

Smita Kapse

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

145 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

Is it possible to write to MongoDB console in JavaScript execution?

Smita Kapse

Smita Kapse

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

84 Views

To write on console, you need to use print() method. The syntax is as follows −print(“yourString”);To display objects, you can use printjson(). The syntax is as follows −printjson(yourObjectName);Let us implement both the functions. The first query is as follows to display something −> print("Welcome to MongoDB Console");The following is the ... Read More

How to sort more than one column at a time in MySQL?

Smita Kapse

Smita Kapse

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

86 Views

To sort more than one column at a time, you can use ORDER BY clause. Following is the syntax −select yourColumnName1, yourColumnName2, yourColumnName3 from yourTableName order by yourColumnName2, yourColumnName3;Let us first create a table −mysql> create table doubleSortDemo    -> (    -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, ... Read More

C++ Program to Implement the String Search Algorithm for Short Text Sizes

Smita Kapse

Smita Kapse

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

345 Views

In this C++ program, as input, a text and a pattern are given. As output, the pattern is searched in the text and all instances of the pattern are given.AlgorithmBegin    Take the string and pattern as input.    Declare the original and duplicate array with their size.    Put ... Read More

MongoDB 'count()' is very slow. How do we work around with it?

Smita Kapse

Smita Kapse

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

1K+ Views

You can use ensureIndex() to boost the performance of count() method in MongoDB. 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.countPerformanceDemo.insertOne({"StudentName":"John", "StudentCountryName":"US"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c8ebcf82f684a30fbdfd55f") } ... Read More

Resolve MySQL ERROR 1064 (42000): You have an error in your syntax?

Smita Kapse

Smita Kapse

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

6K+ Views

This error occurs if let’s say you used var_char instead of varchar type. To remove this type of error, use, for example, varchar(100) instead of var_char(100).Let us now see how this error occurs −mysql> create table removeErrorDemo    -> (    -> StudentId int,    -> StudentName var_char(50)    -> ... Read More

Advertisements