Skip to content

Instantly share code, notes, and snippets.

@wickywills
Created October 2, 2019 09:33
Show Gist options
  • Save wickywills/cdfc35aee006dbe83dcc34e042ef35d3 to your computer and use it in GitHub Desktop.
Save wickywills/cdfc35aee006dbe83dcc34e042ef35d3 to your computer and use it in GitHub Desktop.
## Differences between MySQL and MongoDB
Selecting records from the customer table:
```
MySQL: SELECT * FROM customer
MongoDB: db.customer.find()
```
Inserting records into the customer table:
```
MySQL: INSERT INTO customer (cust_id, branch, status) VALUES ('appl01', 'main', 'A')
MongoDB: db.customer.insert({ cust_id: 'appl01', branch: 'main', status: 'A' })
```
Updating records in the customer table:
```
MySQL: UPDATE customer SET branch = 'main' WHERE custage > 2
MongoDB: db.customer.update( { custage: { $gt: 2 } }, { $set: { branch: 'main' } }, { multi: true } )
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment