Smita Kapse has Published 558 Articles

Fetch domain name by passing name in MySQL?

Smita Kapse

Smita Kapse

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

255 Views

To fetch domain name by passing name in MySQL, you can use substring_index(). Let us first create a table −mysql> create table DemoTable ( UserId int NOT NULL AUTO_INCREMENT PRIMARY KEY, UserMailId varchar(200) ); Query OK,  0 rows affected (0.77 sec)Insert some records in the table using ... Read More

MongoDB query to find documents having two values in an array conforming to multiple criteria?

Smita Kapse

Smita Kapse

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

253 Views

For this, use $elemMatch operator. Let us first create a collection with documents −> db.findDocumentsHaving2Demo.insertOne(    {_id : 101, Values: [78, 98]} ); { "acknowledged" : true, "insertedId" : 101 } > db.findDocumentsHaving2Demo.insertOne(    {_id :102, Values : [89, 102]} ); { "acknowledged" : true, "insertedId" : 102 }Following is ... Read More

Count items in a MySQL table with type ENUM involved?

Smita Kapse

Smita Kapse

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

691 Views

You can use GROUP BY along with aggregate function COUNT(). Let us first create a table −mysql> create table DemoTable    (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Size ENUM('S', 'M', 'L', 'XL')    ); Query OK, 0 rows affected (0.69 sec)Insert some records in the table ... Read More

Perform MongoDB array concatenation to concatenate records

Smita Kapse

Smita Kapse

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

88 Views

For array concatenation, use $concatArrays operator. Let us first create a collection with documents −>db.arrayConcatenationDemo.insertOne({"TeacherName":["Chris", "Robert"], "StudentName":["Mike", "Sam"]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ce921c078f00858fb12e911") }Following is the query to display all documents from a collection with the help of find() method −> db.arrayConcatenationDemo.find().pretty();This will produce the following ... Read More

MySQL system variable table_type doesn't work?

Smita Kapse

Smita Kapse

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

58 Views

The variable table_type doesn’t work since this variable is deprecated as of MySQL 5.5.3. Use default_storage_engine instead. Following is the syntax −SET default_storage_engine = yourTableEngine;The table engine name may be InnoDB or MyISAM. Here, we will set engine type to MyISAM −mysql> SET default_storage_engine=MyISAM; Query OK,  0 rows affected (0.00 sec)Let us create a table.mysql> create ... Read More

Removing empty fields from MongoDB

Smita Kapse

Smita Kapse

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

375 Views

To remove empty fields, use deleteMany(). Let us first create a collection with documents −> db.removeEmptyFieldsDemo.insertOne({"StudentName":""}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ce92b9578f00858fb12e919") } > db.removeEmptyFieldsDemo.insertOne({"StudentName":"Chris"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ce92b9878f00858fb12e91a") } > db.removeEmptyFieldsDemo.insertOne({"StudentName":""}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ce92b9c78f00858fb12e91b") } ... Read More

How to use MySQL CASE statement while using UPDATE Query?

Smita Kapse

Smita Kapse

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

440 Views

For using MySQL CASE statement while using UPDATE Query, you can use CASE statement. Let us first create a table −mysql> create table DemoTable    (    UserId int NOT NULL AUTO_INCREMENT PRIMARY KEY, UserScore int    ); Query OK, 0 rows affected (0.29 sec)Insert some records in the table ... Read More

Retrieving array values from a find query in MongoDB?

Smita Kapse

Smita Kapse

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

87 Views

To retrieve array values, use dot(.) notation. Let us first create a collection with documents −> db.retrievingArrayDemo.insertOne(    { "UserDetails" : [       { "UserName" : "John",  "UserAge" : 23 } ],       "UserCountryName" : "AUS",       "UserLoginDate" : new ISODate(),       "UserMessage" : "Hello"    } ); {    "acknowledged" : true,    "insertedId" : ObjectId("5ce9718478f00858fb12e920") } > db.retrievingArrayDemo.insertOne(    { "UserDetails" : [       ... Read More

Get the sum of a column in all MySQL rows?

Smita Kapse

Smita Kapse

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

166 Views

Use aggregate function SUM() to get the sum of a column in al rows. Let us first create a table −mysql> create table DemoTable    (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Amount int    ); Query OK, 0 rows affected (0.20 sec)Insert some records in the table ... Read More

Hang Up Your iPhone with the Click of a Button

Smita Kapse

Smita Kapse

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

188 Views

When you’re on a call, you can hang up the phone by pressing the Side button on your iOS device. This button is also called as sleep/wake up or lock button.The devices and iOS are specifically designed the way that pressing the power button while on a call will immediately ... Read More

Advertisements