0

I have a mysql (MariaDB) table with a plenty of lines. I deleted by mistate a row. And I would like to recover it from a backup.

This is the row I found in the sql backup file:

| 186 | {"price":8990,"quantity":1,"shipping":0,"electronicShipping":false,"description":"xxxx \"yyy uuu iii\" + xyz xyz","cname":"Name LastName","fname":"Name","email":"asdfdsa@afsfa.com","phone":"76543765","address":"sadfas123/avc","city":"XXX","state":"vvvv","zip":"654326","newsletter":true,"product":{"sku":"pakiet","name":"YUIa \"sdfghjk\" + xyz sfas","description":"YYYY \"xxxx yyyy zzzz\" + xyz xyz xyz + 3 xyz yyyy xxxx","originalPrice":149.6,"price":89.9,"vat":5,"shipping":0,"electronicShipping":false,"discount":59.7,"category":["drukowane","ebooki"],"image":"/images/xxx.jpg","shopImage":"/images/tyyyy.jpg","template":"d-idsgiosdjgiodjsgs","links":[{"file":"xyz.mobi","name":"File Name"},{"file":"zxvfsdfs.epub","name":"File name"},{"file":"sdfasfdw.pdf","name":"File name"},{"file":"asdgdsagds.pdf","name":"File name"}],"mailerLiteGroupID":[11111,22222],"sendgridListIds":["456789-54321-6543-654","76543-654327-6543"],"mailerLiteBuyersGroupID":[1234,12345]},"privacy":true,"terms":true,"comment":"","template":"d-234567890","vat":false,"vatCompany":"","vatNip":"","vatAddress":"","vatCity":"","vatState":"","vatZip":"","status":1,"extra":null,"selectAll":true,"statement":"34-3242-2345"} |     1 | 2021-12-24 15:21:52 | 2021-12-24 15:22:12 |  1560281088 | NULL | NULL      |

I am trying to add it this way:

INSERT INTO Orders (id, body, state, createdAt, updatedAt, orderNumber, send, invoice)
    -> VALUES (186, {"price":8990,"quantity":1,"shipping":0,"electronicShipping":false,"description":"xxxx \"yyy uuu iii\" + xyz xyz","cname":"Name LastName","fname":"Name","email":"asdfdsa@afsfa.com","phone":"76543765","address":"sadfas123/avc","city":"XXX","state":"vvvv","zip":"654326","newsletter":true,"product":{"sku":"pakiet","name":"YUIa \"sdfghjk\" + xyz sfas","description":"YYYY \"xxxx yyyy zzzz\" + xyz xyz xyz + 3 xyz yyyy xxxx","originalPrice":149.6,"price":89.9,"vat":5,"shipping":0,"electronicShipping":false,"discount":59.7,"category":["drukowane","ebooki"],"image":"/images/xxx.jpg","shopImage":"/images/tyyyy.jpg","template":"d-idsgiosdjgiodjsgs","links":[{"file":"xyz.mobi","name":"File Name"},{"file":"zxvfsdfs.epub","name":"File name"},{"file":"sdfasfdw.pdf","name":"File name"},{"file":"asdgdsagds.pdf","name":"File name"}],"mailerLiteGroupID":[11111,22222],"sendgridListIds":["456789-54321-6543-654","76543-654327-6543"],"mailerLiteBuyersGroupID":[1234,12345]},"privacy":true,"terms":true,"comment":"","template":"d-234567890","vat":false,"vatCompany":"","vatNip":"","vatAddress":"","vatCity":"","vatState":"","vatZip":"","status":1,"extra":null,"selectAll":true,"statement":"34-3242-2345"}, 1, 2021-12-24 15:21:52, 2021-12-24 15:22:12, 2634022912, NULL, NULL);

But it's giving me:

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"price":8990,"quantity":1,"shipping":0,"electronicShipping":false,"description":' at line 2

Can anybody help me to add this line to the Orders table?

utnalove
  • 159
  • 6
  • 1
    SQL is not JSON. You cannot have JSON as a raw literal in SQL. MySQL is not MariaDB (though they are compatible with each other, please use only a single tag for the _specific_ RDBMS you're using) – Dai Dec 26 '21 at 13:49
  • what do you mean single tag? Does it mean wrapping the object with double quotes? – utnalove Dec 26 '21 at 13:51
  • No, the StackOverflow _question tags_ displayed below your post. – Dai Dec 26 '21 at 13:51
  • @utnalove Use single quotes for strings in your query, see https://stackoverflow.com/questions/11321491/when-to-use-single-quotes-double-quotes-and-backticks-in-mysql#:~:text=Single%20quotes%20should%20be%20used,single%20quotes%20instead%20of%20double. – Progman Dec 26 '21 at 14:24

0 Answers0