PASS JSON DATA FROM ONE TABLE TO ANOTHER IN MYSQL

0

Hi, I would like to know if someone can help me with this inconvenience that I have. In a column of a table in Mysql a list JSON is saved like this:

    {
  "Sender": "[email protected]",
  "X-Mailgun-Sending-Ip": "198.61.254.10",
  "X-Mailgun-Sid": "WyI5MTY2ZiIsICJmYXVzdG9fY2FyY2hpQGhvdG1haWwuaXQiLCAiMGQ3OWM4Il0=",
  "List-Unsubscribe": "<mailto:u+mq6tazbxhfrtqjtjhvsdgojugu3dinzvmy2gknbxgnstmzddhe4wcojxgazdeyzqg44wmjjugbzxo2lgoqxgozlomvzgc5dfmqtgqplemu3donjrha2wmzjqgy2tmzjtmvrtgmruha2dsyjzhe4dgobxmuthepkgmf2xg5dpl5rwc4tdnbusknbqnbxxi3lbnfwc42luez2d2jjsie@mg.gminfoleads.com>",
  "Received": "from [127.0.0.1] (server.provendatarecovery.com [144.208.68.130]) by mxa.mailgun.org with ESMTP id 595e7aa5.7f65c8243c30-smtp-out-n01; Thu, 06 Jul 2017 18:00:05 -0000 (UTC)",
  "Message-Id": "<[email protected]>",
  "Date": "Thu, 06 Jul 2017 13:00:04 -0500",
  "Subject": "Est\u00e1s un paso m\u00e1s cerca de tu nuevo auto",
  "From": "Chevrolet Ecuador <[email protected]>",
  "To": "[email protected]",
  "Mime-Version": "1.0",
  "Content-Type": [
    "text\/html",
    {
      "charset": "utf-8"
    }
  ],
  "Content-Transfer-Encoding": [
    "quoted-printable",
    {}
  ]
}

What I want to know is how to pass the data to another table where you have each of the fields in the list JSON separately by using tiggers .

I hope you can help me thanks.

    
asked by Christian Esk 16.03.2018 в 16:51
source

1 answer

1

I think you could do it in the following way

DELIMITER //

CREATE TRIGGER insert_jason
AFTER INSERT
   ON tabla1 FOR EACH ROW
BEGIN
   INSERT INTO tabla2( columnajson)VALUES(NEW.columnaJson);
END; //

DELIMITER ;

What this code does is that every time you insert something in the tabla1 an insert will be executed in the tabla2 , then the table2 has to have the same field as the table 1 to be able to do the insert (this must be verified), then the values(NEW.columnajson) will take the value of the field that is inserted in the table1. I think that would be an example with the information you gave me.

    
answered by 16.03.2018 / 20:37
source