O'Reilly logo

MySQL 8 Cookbook by Karthik Appigatla

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How to do it...

  1. Consider the emp_details table that you created in Chapter 3, Using MySQL (Advanced)Using JSON section:
mysql> SHOW CREATE TABLE emp_details\G*************************** 1. row ***************************       Table: emp_detailsCreate Table: CREATE TABLE `emp_details` (  `emp_no` int(11) NOT NULL,  `details` json DEFAULT NULL,  PRIMARY KEY (`emp_no`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb41 row in set (0.00 sec)
  1. Insert a few dummy records:
mysql> INSERT IGNORE INTO emp_details(emp_no, details) VALUES      ('1', '{ "location": "IN", "phone": "+11800000000", "email": "abc@example.com", "address": { "line1": "abc", "line2": "xyz street", "city": "Bangalore", "pin": "560103"}}'), ('2', '{ "location": "IN", "phone": "+11800000000", "email": ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required