Getting started Mysql with JSON

Getting started Mysql with JSON

Let us create a table playes


CREATE TABLE `players` (  
  `id` INT NOT NULL,
  `player_and_games` varchar(5000),
  PRIMARY KEY (`id`)
);
 
 
Insert JSON data into table 
 
INSERT INTO `players` (`id`, `player_and_games`) VALUES (1, '{  
    "name": "Sally",  
    "games_played":{    
       "Battlefield": "yes",                    
                                                                        
                              
       "Crazy Tennis": "yes",  
       "Puzzler": {                             
                                                                        
                                                                        
                                                                        
                                                                        
                                                                  
          "time": 7
        }
      }
   }'
)
 
INSERT INTO `players` (`id`, `player_and_games`) VALUES (2, '{  
    "name": "radhey",  
    "games_played":{    
       "Battlefield": "no",                    
                                                                        
                              
       "Crazy Tennis": "no",  
       "Puzzler": {                             
                                                                        
                                                                        
                                                                        
                                                                        
                                                                  
          "time": 7
        }
      }
   }'
)  

Comments

Popular posts from this blog

How to get the parameter from url in codeigniter?

MySQL event scheduler and how to create MySQL events to automate database tasks