How is their query different?

  • Selecting records from the users table:
    MySQL: SELECT * FROM users
    MongoDB: db.users.find ()
  • Inserting records into the users table:
    MySQL: INSERT INTO users (user_id, fname, lname, phone) VALUES (‘jane’, ‘deo’, ‘7858458891’)
    MongoDB: db.users.insert ({user_id :’1’, fname: ‘jane’, lname: ‘deo’, phone: ”7858458891′ })
  • Updating records in the users table:
    MySQL: UPDATE users SET fname = ‘Robert’ WHERE user_id = 2
    MongoDB: db.users.update( { user_id: { $eq: 2 } }, { $set: { fname: ‘Robert ‘ } }, { multi: true } )

When to use MySQL and MongoDB :

MySQL and MongoDB both have their weaknesses and strengths. you should take care about your project requirements.

Pros and Cons of MongoDB and MySQL :

MySQL

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store