Anvi Jain has Published 629 Articles

Update multiple rows in a single column in MySQL?

Anvi Jain

Anvi Jain

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

3K+ Views

To update multiple rows in a single column, use CASE statement. Let us first create a table −mysql> create table updateMultipleRowsDemo    -> (    -> StudentId int,    -> StudentMathScore int    -> ); Query OK, 0 rows affected (0.63 sec)Following is the query to insert records in the ... Read More

C++ Program to Implement Queue Using Two Stacks

Anvi Jain

Anvi Jain

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

2K+ Views

StackThe stack which is implemented as LIFO, where insertion and deletion are done from the same end, top. The last element that entered is deleted first.Stack operations are −push (int data) − Insertion at topint pop() − Deletion from topQueueThe queue which is implemented as FIFO where insertions are done ... Read More

MySQL search if more than one string contains special characters?

Anvi Jain

Anvi Jain

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

2K+ Views

To search if strings contain special characters, you can use REGEXP. Following is the syntax −select * from yourTableName where yourColumnName REGEXP '[^a-zA-Z0-9]';Let us first create a table −mysql> create table specialCharactersDemo    -> (    -> StudentId varchar(100)    -> ); Query OK, 0 rows affected (0.58 sec)Insert records ... Read More

How to use quote () in Android sqlite?

Anvi Jain

Anvi Jain

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

163 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

C++ Program to Implement Dequeue

Anvi Jain

Anvi Jain

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

9K+ Views

Dequeue or Double Ended Queue is a generalized version of Queue data structure that allows insert and delete at both ends.Some basic operations of dequeue are −insert_at_beg(): inserts an item at the front of Dequeue.insert_at_end(): inserts an item at the rear of Dequeue.delete_fr_beg(): Deletes an item from front of Dequeue.delete_fr_rear(): ... 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

479 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

727 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

268 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

Advertisements