Anvi Jain has Published 569 Articles

How to use quote () in Android sqlite?

Anvi Jain

Anvi Jain

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

246 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 calculate value from multiple columns in MySQL?

Anvi Jain

Anvi Jain

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

1K+ Views

To calculate a value from multiple columns, use GROUP BY. Following is the syntax −select yourColumnName1, sum(yourColumnName2*yourColumnName3) AS anyAliasName from yourTableName group by yourColumnName1;Let us first create a table −mysql> create table calculateValueDemo    -> (    -> Id int,    -> ProductPrice int,    -> ProductWeight int    -> ... Read More

The collection.find() always returns all fields with MongoDB?

Anvi Jain

Anvi Jain

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

580 Views

You can return a specific field from collection.find() by using the following syntax.Case 1 − The syntax is as follows −db.yourCollectionName.find({}, {"yourFieldName":1}).pretty();The above field name is set to 1 means it will return only that field. If you set to 0 it will return all fields except the field which ... Read More

C++ Program to Construct Transitive Closure Using Warshall’s Algorithm

Anvi Jain

Anvi Jain

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

902 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 reach-ability matrix is called transitive closure of a graph. Warshall ... Read More

How to use the CAST function in a MySQL SELECT statement?

Anvi Jain

Anvi Jain

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

374 Views

The CAST() function in MySQL converts a value of any type into a value that has a specified type. Let us first create a table −mysql> create table castFunctionDemo    -> (    -> ShippingDate date    -> ); Query OK, 0 rows affected (0.74 sec)Following is the query to ... Read More

C++ Program to Implement Traveling Salesman Problem using Nearest Neighbour Algorithm

Anvi Jain

Anvi Jain

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

1K+ Views

Here is a C++ Program to Implement Traveling Salesman Problem using Nearest Neighbour Algorithm.Required functions and pseudocodesAlgorithmBegin    Initialize c = 0, cost = 1000;    Initialize g[][].    function swap() is used to swap two values x and y.    function cal_sum() to calculate the cost which take array ... Read More

MySQL format time with lowercase am/pm?

Anvi Jain

Anvi Jain

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

748 Views

To format MySQL time with lowercase am/pm, use the LOWER() as well as DATE_FORMAT().Let us first create a table −mysql> create table formatTime    -> (    -> LoginTime time    -> ); Query OK, 0 rows affected (0.56 sec)Following is the query to insert records in the table using ... Read More

C++ program to Check if a Given Binary Tree is an AVL Tree or Not

Anvi Jain

Anvi Jain

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

2K+ Views

AVL tree is a self-balancing Binary Search Tree where the difference between heights of left and right subtrees cannot be more than one for all nodes.This is a C++ program to check if a given Binary Tree is an AVL Tree or not.AlgorithmBegin function AVL() returns true if the given ... Read More

Reorder integer except for value 0 with MySQL?

Anvi Jain

Anvi Jain

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

96 Views

To reorder integer except for value 0, use the below syntax −select *from yourTableName order by yourColumnName=0 ,yourColumnName;Let us first create a table −mysql> create table reorderIntegerExcept0    -> (    -> value int    -> ); Query OK, 0 rows affected (0.70 sec)Following is the query to insert records ... Read More

How to generate different random numbers in a loop in C++?

Anvi Jain

Anvi Jain

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

4K+ Views

Let us see how to generate different random numbers using C++. Here we are generating random numbers in range 0 to some value. (In this program the max value is 100).To perform this operation we are using the srand() function. This is in the C++ library. The function void srand(unsigned ... Read More

Advertisements