[mysql] JSON数据操作

/ 37,042评论 / 148748阅读 / 0点赞

前言

在MySql中使用

声明json类型的字段

create table test(
    uids json not null default ('[]')
);
default ('[{"name":"coolight"}, {"name","洛天依"}]')
或
default ("[{'name':'coolight'}, {'name','洛天依'}]")

Mysql中常用的操作json函数

JSON_LENGTH(json1)=JSON_LENGTH(json2) and JSON_CONTAINS(json1, json2)
// 例如:
update test set enable=true where JSON_LENGTH(json1)=JSON_LENGTH(json2) and JSON_CONTAINS(json1, json2);
// 示例:在数组末尾追加元素
SELECT JSON_ARRAY_APPEND('[1, 2, 3]', '$', 4); 
// 得到 [1,2,3,4]

// 示例:对数组添加一个元素,如果已经存在则不添加
// ["1000000", "1000001", "1000002"]
update test set uids=json_array_append(uids, '$','1000001') where id=777 and JSON_CONTAINS(uids,JSON_ARRAY('1000001'))=0;
// 没有添加,注意where ... and 后面 使用JSON_CONTAINS判断了是否包含准备添加的元素
// ["1000000", "1000001", "1000002"]
update test set uids=json_remove(uids, JSON_UNQUOTE(JSON_SEARCH(uids, 'one','1000001'))) where id=777;
// ["1000000", "1000002"]
create TRIGGER auto_reset after insert on test for each row
BEGIN
    update test set uids=json_array_append(uids, '$', CAST(NEW.uid as char)) where id=NEW.id;
END;
  1. MarvinMek说道:

    where can i buy amoxocillin amoxicillin buy online canada amoxicillin price canada

  2. HenryIsona说道:

    purchase amoxicillin online: amoxicillin 500mg for sale uk – order amoxicillin online no prescription

  3. MarvinMek说道:

    purchase amoxicillin 500 mg [url=http://amoxila.pro/#]ampicillin amoxicillin[/url] amoxicillin 775 mg

  4. Richardfrota说道:

    amoxicillin 30 capsules price: amoxicillin generic – amoxicillin 500 mg

  5. lose money说道:

    I highly advise steer clear of this site. My own encounter with it was purely frustration and doubts about scamming practices. Exercise extreme caution, or even better, find an honest platform to meet your needs.

  6. lose money说道:

    I highly advise stay away from this site. My personal experience with it has been purely dismay as well as doubts about fraudulent activities. Exercise extreme caution, or alternatively, seek out a trustworthy platform to fulfill your requirements.

  7. lose money说道:

    I strongly recommend stay away from this platform. The experience I had with it has been only frustration as well as suspicion of deceptive behavior. Be extremely cautious, or even better, find a trustworthy platform to meet your needs.

  8. lose money说道:

    I highly advise steer clear of this site. My personal experience with it has been nothing but frustration as well as suspicion of fraudulent activities. Be extremely cautious, or even better, look for an honest service to meet your needs.

  9. Billyeroge说道:

    http://prednisoned.online/# prednisone 60 mg daily

  10. HenryIsona说道:

    buy prednisone online no script: prednisone pill prices – order prednisone online canada

  11. lose money说道:

    I highly advise stay away from this site. The experience I had with it has been purely dismay along with suspicion of fraudulent activities. Exercise extreme caution, or better yet, seek out a more reputable platform to fulfill your requirements.

  12. MarvinMek说道:

    buying amoxicillin in mexico order amoxicillin online amoxicillin 500 mg where to buy

  13. CharlesGib说道:

    zithromax 250mg: can you buy zithromax over the counter in mexico – zithromax z-pak price without insurance

  14. lose money说道:

    I urge you stay away from this platform. My personal experience with it has been purely frustration along with suspicion of scamming practices. Exercise extreme caution, or better yet, look for an honest service to meet your needs.

  15. HenryIsona说道:

    generic amoxicillin 500mg: buy amoxicillin 500mg capsules uk – amoxicillin 250 mg capsule

  16. lose money说道:

    I strongly recommend to avoid this platform. My own encounter with it was purely frustration along with doubts about scamming practices. Be extremely cautious, or even better, seek out a trustworthy service to meet your needs.

  17. MarvinMek说道:

    drug prices prednisone [url=https://prednisoned.online/#]prednisone otc uk[/url] prednisone 2.5 mg price

  18. lose money说道:

    I highly advise to avoid this platform. The experience I had with it has been only frustration along with doubts about deceptive behavior. Be extremely cautious, or even better, seek out an honest platform to meet your needs.

  19. Richardfrota说道:

    prednisone in canada: prednisone for sale no prescription – average cost of prednisone 20 mg

  20. CharlesGib说道:

    prednisone 500 mg tablet: buy prednisone online without a prescription – canine prednisone 5mg no prescription

  21. HenryIsona说道:

    50 mg prednisone tablet: prednisone 5mg daily – prednisone otc price

  22. Billyeroge说道:

    https://prednisoned.online/# where to buy prednisone without prescription

  23. Billyeroge说道:

    https://amoxila.pro/# price of amoxicillin without insurance

  24. MarvinMek说道:

    neurontin 300 mg generic neurontin 600 mg brand name neurontin

  25. HenryIsona说道:

    where can i buy zithromax medicine: zithromax cost canada – zithromax 250 mg australia

  26. MarvinMek说道:

    buying neurontin without a prescription [url=http://gabapentinneurontin.pro/#]cost of neurontin 600 mg[/url] neurontin over the counter

  27. HenryIsona说道:

    amoxicillin discount coupon: buy amoxicillin 500mg uk – how to buy amoxicillin online

  28. Mafecs说道:

    viagra professional online somewhere – viagra gold sort levitra oral jelly online load

  29. Richardfrota说道:

    cheap doxycycline online: buy doxycycline – doxycycline 50mg

  30. HenryIsona说道:

    prednisone tablet 100 mg: prednisone price south africa – prednisone 40 mg

  31. CharlesGib说道:

    amoxicillin 500 mg capsule: how much is amoxicillin – amoxicillin 500mg capsules

  32. HenryIsona说道:

    prednisone acetate: cheapest prednisone no prescription – 20mg prednisone

  33. Richardfrota说道:

    how much is amoxicillin prescription: where to buy amoxicillin over the counter – amoxicillin 500mg capsule buy online

  34. Dayson_dtmt说道:

    фен аналог дайсон http://www.dyson-feny.com .

  35. scam说道:

    I urge you stay away from this platform. The experience I had with it has been only dismay along with suspicion of scamming practices. Proceed with extreme caution, or even better, find a more reputable site for your needs.

  36. lose money说道:

    I urge you steer clear of this platform. My own encounter with it was nothing but frustration along with suspicion of fraudulent activities. Be extremely cautious, or even better, seek out an honest service to meet your needs.

  37. CharlesGib说道:

    online doxycycline: doxycycline monohydrate – price of doxycycline

  38. scam说道:

    I urge you to avoid this platform. My personal experience with it was nothing but dismay along with suspicion of fraudulent activities. Exercise extreme caution, or even better, seek out an honest platform for your needs.

  39. HenryIsona说道:

    doxycycline generic: generic doxycycline – doxycycline 100mg price

  40. Billyeroge说道:

    http://zithromaxa.store/# zithromax 500 price

  41. With regards to discovering an ideal companion on your intimate wishes, almost nothing beats the experience of the best sexual intercourse doll.

  42. Billyeroge说道:

    https://gabapentinneurontin.pro/# buy neurontin online uk

  43. MarvinMek说道:

    zithromax cost canada generic zithromax medicine zithromax drug

  44. This is the argument being made by the Moonlite Bunny Ranch sex worker, Summer Sebastian, who recently announced that she’s pregnant and that she plans to keep working until she’s due.

  45. HenryIsona说道:

    cost of amoxicillin prescription: generic amoxicillin 500mg – amoxicillin 500 mg without a prescription

  46. MarvinMek说道:

    amoxicillin 500 mg cost [url=https://amoxila.pro/#]amoxicillin online without prescription[/url] can you purchase amoxicillin online

  47. Richardfrota说道:

    order doxycycline online: doxycycline 150 mg – doxycycline hyclate

  48. HenryIsona说道:

    medicine amoxicillin 500: amoxicillin 500mg capsules uk – amoxicillin for sale

  49. Billyeroge说道:

    https://doxycyclinea.online/# generic doxycycline

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注