Anvi Jain has Published 569 Articles

Replace part of string in MySQL table column?

Anvi Jain

Anvi Jain

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

454 Views

To replace part of string in MySQL table column, you can use REPLACE(). Following is the syntax −update yourTableName set yourColumnName = REPLACE(yourColumnName ,'yourOldValue', 'yourNewValue');Let us first create a table −mysql> create table replacePartOfStringDemo    -> (    -> WebsiteURL varchar(100)    -> ); Query OK, 0 rows affected (0.47 ... Read More

How to get latitude from Network provider in android?

Anvi Jain

Anvi Jain

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

302 Views

This example demonstrate about How to get latitude 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. In the ... Read More

How to get element with max id in MongoDB?

Anvi Jain

Anvi Jain

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

1K+ Views

To get the element with a max id, you can use the find() method. To understand the above concept, let us create a collection with the document. The query is as follows −> db.getElementWithMaxIdDemo.insertOne({"Name":"John", "Age":21}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c8bbce480f10143d8431e1c") } > db.getElementWithMaxIdDemo.insertOne({"Name":"Larry", "Age":24}); {   ... Read More

The most elegant way to iterate the words of a string using C++

Anvi Jain

Anvi Jain

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

155 Views

There is no one elegant way to iterate the words of a C/C++ string. The most readable way could be termed as the most elegant for some while the most performant for others. I've listed 2 methods that you can use to achieve this. First way is using a stringstream ... Read More

Remove Trailing Zero in MySQL?

Anvi Jain

Anvi Jain

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

2K+ Views

Use trim() function to remove trailing zeroz in MySQL. Following is the syntax −select trim(yourColumnName)+0 As anyAliasName from yourTableName;Let us first create a table −mysql> create table removeTrailingZero    -> (    -> Number DECIMAL(10, 4)    -> ); Query OK, 0 rows affected (0.83 sec)Following is the query to ... Read More

MySQL query to find sum of fields with same column value?

Anvi Jain

Anvi Jain

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

783 Views

Use GROUP BY clause for this. Let us first create a table −mysql> create table sumOfFieldsDemo    -> (    -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> ClientSerialNumber varchar(100),    -> ClientCost int    -> ); Query OK, 0 rows affected (0.50 sec)Following is the query to ... Read More

How to use length () in Android sqlite?

Anvi Jain

Anvi Jain

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

460 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

Case insensitive search in Mongo?

Anvi Jain

Anvi Jain

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

3K+ Views

You can restrict case insensitive search in MongoDB with the help of '$regex'. The syntax is as follows −db.yourCollectionName.find({"yourFieldName" : { '$regex':'^yourValue$'}});You can use another regex. The syntax is as follows −db.yourCollectionName.find({"Name" : { '$regex':/^yourValue$/i}});To understand the concept, let us create a collection with the document. The query to create ... Read More

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

MySQL search if more than one string contains special characters?

Anvi Jain

Anvi Jain

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

3K+ 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

Advertisements