- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 6702 Articles for Database
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
1K+ Views
To get distinct values from object array in MongoDB, use distinct(). Let us create a collection with documents −> db.demo442.insertOne( ... { ... ... "Information" : [ ... { ... "FirstName" : "John", ... "Age" : 21 ... }, ... { ... "FirstName" : "Sam", ... "Age" : 23 ... }, ... ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
592 Views
For this, use UPDATE command along with REGEXP. Let us first create a table −mysql> create table DemoTable2023 -> ( -> StreetNumber varchar(100) -> ); Query OK, 0 rows affected (0.59 sec)Insert some records in the table using insert command −mysql> insert into DemoTable2023 values('7'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable2023 values('1'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable2023 values('AUS-100'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable2023 values('US-101'); Query OK, 1 row affected (0.11 sec)Display all records from the table using ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
1K+ Views
To insert multiple values in a column, the syntax is as follows −insert into yourTableName values(yourValue1), (yourValue2), ..........N;To understand the above syntax, let us create a table −mysql> create table DemoTable2022 -> ( -> Department varchar(100) -> ); Query OK, 0 rows affected (0.49 sec)Insert some records in the table using insert command −mysql> insert into DemoTable2022 values('Computer Science'), ('Information Technology'), ('Civil'), ('Mechanical'), ('Electronics'), ('Electrical'); Query OK, 6 rows affected (0.46 sec) Records: 6 Duplicates: 0 Warnings: 0Display all records from the table using select statement −mysql> select *from DemoTable2022;This will produce the following ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
982 Views
To insert data from one scheme to another, the syntax is as follows. Here, we have two databases “yourDatabaseName1” and “yourDatabaseName2” −insert into yourDatabaseName2.yourTableName2 select *from yourDatabaseName1.yourTableName1;To understand the above syntax, let us create a table. We are creating a table in database “web” −mysql> create table DemoTable2020 -> ( -> Id int, -> Name varchar(20) -> ); Query OK, 0 rows affected (0.67 sec)Insert some records in the table using insert command −mysql> insert into DemoTable2020 values(101, 'Chris'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable2020 values(102, 'David'); Query OK, 1 ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
959 Views
To aggregate nested array in MongoDB, use aggregate(). Let us create a collection with documents −> db.demo441.insertOne( ... { ... ... "Name" : "David", ... "Age" : 21, ... ... "details" : [ ... { ... "id" : 1, ... "CountryName" : "US", ... "details1" : [ ... { ... "SubjectName" : ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
213 Views
To count items in array, use length. Let us create a collection with documents −> db.demo440.insertOne( ... { ... "Name":"Chris", ... "ListOfFriends":["John", "Sam", "Mike"] ... } ... ); { "acknowledged" : true, "insertedId" : ObjectId("5e78c63cbbc41e36cc3caeb5") } > > db.demo440.insertOne( ... { ... "Name":"David", ... "ListOfFriends":["Mike", "Bob", "Carol"] ... } ... ); { "acknowledged" : true, "insertedId" : ObjectId("5e78c63cbbc41e36cc3caeb6") }Display all documents from a collection with the help of find() method −> db.demo440.find();This will produce the following output −{ "_id" : ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
158 Views
To project field in MongoDB, use $project. Let us create a collection with documents −> db.demo439.insertOne( ... { ... "Name" : "Chris", ... "MarksInformation" : { ... "Marks1" : 67, ... "Marks2" :45, ... "Marks3" : 78 ... } ... } ... ); { "acknowledged" : true, "insertedId" : ObjectId("5e77833abbc41e36cc3caeab") } > db.demo439.insertOne( ... { ... "Name" : "David", ... "MarksInformation" : { ... ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
667 Views
To update field with GROUP BY, use ORDER BY LIMIT with UPDATE command −mysql> create table DemoTable2018 -> ( -> EmployeeId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> EmployeeName varchar(20), -> EmployeeSalary int -> ); Query OK, 0 rows affected (0.61 sec)Insert some records in the table using insert command −mysql> insert into DemoTable2018(EmployeeName, EmployeeSalary) values('Chris', 10000); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable2018(EmployeeName, EmployeeSalary) values('David', 12560); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable2018(EmployeeName, EmployeeSalary) values('Chris', 25400); Query OK, 1 row affected (0.09 sec)Display all ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
688 Views
Let us first create a table −mysql> create table DemoTable2017 -> ( -> Name text -> ); Query OK, 0 rows affected (0.55 sec)Insert some records in the table using insert command −mysql> insert into DemoTable2017 values('JOHN SMITH, MYSQL'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable2017 values('DAVID MILLER, MONGODB'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable2017 values('CHRIS BROWN, JAVA'); Query OK, 1 row affected (0.11 sec)Display all records from the table using select statement −mysql> select *from DemoTable2017;This will produce the following output −+----------------------+ | Name ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
262 Views
To remove duplicate record, use aggregate(). Let us create a collection with documents −> db.demo438.insertOne({"FirstName":"Chris"}); { "acknowledged" : true, "insertedId" : ObjectId("5e775c37bbc41e36cc3caea1") } > db.demo438.insertOne({"FirstName":"David"}); { "acknowledged" : true, "insertedId" : ObjectId("5e775c3dbbc41e36cc3caea2") } > db.demo438.insertOne({"FirstName":"Chris"}); { "acknowledged" : true, "insertedId" : ObjectId("5e775c40bbc41e36cc3caea3") } > db.demo438.insertOne({"FirstName":"Bob"}); { "acknowledged" : true, "insertedId" : ObjectId("5e775c44bbc41e36cc3caea4") } > db.demo438.insertOne({"FirstName":"David"}); { "acknowledged" : true, "insertedId" : ObjectId("5e775c47bbc41e36cc3caea5") }Display all documents from a collection with the help of find() method −> db.demo438.find();This will produce the following output −{ "_id" : ObjectId("5e775c37bbc41e36cc3caea1"), "FirstName" : "Chris" } { ... Read More