[mysql] JSON数据操作

/ 37,070评论 / 148903阅读 / 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. KennethFobby说道:

    https://mexicanpharmacy1st.shop/# purple pharmacy mexico price list

  2. Robertswela说道:

    mexican mail order pharmacies: pharmacies in mexico that ship to usa – best mexican online pharmacies

  3. Thomasliest说道:

    buying from online mexican pharmacy: п»їbest mexican online pharmacies – mexico pharmacies prescription drugs

  4. Thomasliest说道:

    mexican border pharmacies shipping to usa: mexico pharmacies prescription drugs – best online pharmacies in mexico

  5. Albertnab说道:

    buying from online mexican pharmacy: mexican rx online – best online pharmacies in mexico

  6. Williamlyday说道:

    https://mexicanpharmacy1st.online/# buying prescription drugs in mexico online

  7. they might not have been skilled role models when it came to teaching us how to listen and communicate.our caregivers may have inadvertently taught us the wrong ways to deal with our emotions,ラブドール 中古

  8. Williamlyday说道:

    https://mexicanpharmacy1st.com/# buying prescription drugs in mexico

  9. Robertswela说道:

    mexico pharmacy: mexico drug stores pharmacies – mexican drugstore online

  10. scam说道:

    I strongly recommend to avoid this site. The experience I had with it was only frustration and concerns regarding scamming practices. Be extremely cautious, or better yet, seek out a trustworthy platform for your needs.

  11. Once it’s lubed up,ラブドール えろit slips all over the place,

  12. Manuelloupe说道:

    mexican mail order pharmacies [url=http://mexicanpharmacy1st.com/#]mexico drug stores pharmacies[/url] best online pharmacies in mexico

  13. Robertswela说道:

    buying prescription drugs in mexico online: buying prescription drugs in mexico online – medicine in mexico pharmacies

  14. scam说道:

    I highly advise stay away from this platform. My own encounter with it was nothing but frustration along with concerns regarding deceptive behavior. Be extremely cautious, or alternatively, look for a more reputable service to meet your needs.

  15. criminal说道:

    I highly advise steer clear of this site. My own encounter with it has been purely dismay and doubts about scamming practices. Exercise extreme caution, or alternatively, find a trustworthy platform to meet your needs.

  16. Williamlyday说道:

    https://mexicanpharmacy1st.shop/# pharmacies in mexico that ship to usa

  17. scam说道:

    I strongly recommend to avoid this platform. The experience I had with it was purely frustration as well as doubts about fraudulent activities. Proceed with extreme caution, or even better, seek out a more reputable site to fulfill your requirements.

  18. Williamlyday说道:

    https://mexicanpharmacy1st.online/# reputable mexican pharmacies online

  19. Robertswela说道:

    mexico drug stores pharmacies: mexican online pharmacies prescription drugs – mexican border pharmacies shipping to usa

  20. criminal说道:

    I strongly recommend steer clear of this site. The experience I had with it was nothing but dismay as well as doubts about scamming practices. Exercise extreme caution, or even better, seek out a more reputable site for your needs.

  21. scam说道:

    I highly advise stay away from this site. The experience I had with it has been only frustration as well as concerns regarding deceptive behavior. Exercise extreme caution, or better yet, look for an honest site for your needs.

  22. scam说道:

    I highly advise to avoid this site. My personal experience with it has been only dismay as well as concerns regarding deceptive behavior. Be extremely cautious, or better yet, find an honest site for your needs.

  23. Manuelloupe说道:

    purple pharmacy mexico price list reputable mexican pharmacies online mexican pharmacy

  24. Путаны Москвы devkiru.com

    Если Вы хотите купить вызвать шлюху в Мск, то прямо сейчас переходите на вышеупомянутый сайт. Мы предлагаем купить самых недорогих проституток в Москве. Но в этом вопросе, цена не значит плохое качество. Просто у девушек в данной категории не так много стажа, и принимают они в квартирах чуть далее от центра Москвы и не очень фешенебельных. Не стоит волноваться, что невысокая цена может подпортить Ваш досуг, скорее — наоборот. Шанс обалденно провести свой отдых по хорошей цене-дважды хорошо.

  25. Videosteny_wpEl说道:

    видеостена купить в москве https://www.videosteny14.ru .

  26. Robertswela说道:

    mexico pharmacy: mexican pharmacy – buying from online mexican pharmacy

  27. Manuelloupe说道:

    mexico drug stores pharmacies [url=https://mexicanpharmacy1st.com/#]medication from mexico pharmacy[/url] mexico pharmacies prescription drugs

  28. Albertnab说道:

    reputable mexican pharmacies online: mexican rx online – mexican rx online

  29. KennethFobby说道:

    https://mexicanpharmacy1st.online/# buying from online mexican pharmacy

  30. Заказать девушку на дом Москва devkiru.com

    Если Вы планировали найти индивидуалки от 40 москва в Мск, то прямо сейчас переходите на указанный сайт. Мы предлагаем посмотреть самых дешевых проституток в Москве. Но в этом вопросе, низкая цена не означает плохое качество. Всего лишь у девушек в этой категории не так много стажа, и принимают они в квартирах чуть далее от центра Москвы и не очень фешенебельных. Не нужно переживать, что невысокая цена может подпортить Ваш досуг, правильнее — напротив. Вероятность обалденно провести время по хорошей стоимости-в двойном размере хорошо.

  31. Williamlyday说道:

    https://mexicanpharmacy1st.com/# п»їbest mexican online pharmacies

  32. Robertswela说道:

    mexican pharmacy: medication from mexico pharmacy – mexican drugstore online

  33. 급전说道:

    Your perspective is refreshingly honest.대출

  34. KennethFobby说道:

    http://mexicanpharmacy1st.com/# buying from online mexican pharmacy

  35. Manuelloupe说道:

    mexican rx online mexico pharmacies prescription drugs mexico pharmacy

  36. Robertswela说道:

    mexico pharmacy: mexican online pharmacies prescription drugs – mexico drug stores pharmacies

  37. scam说道:

    I highly advise to avoid this platform. The experience I had with it was purely frustration and suspicion of fraudulent activities. Be extremely cautious, or alternatively, look for a more reputable service to meet your needs.

  38. scam说道:

    I strongly recommend stay away from this site. My personal experience with it has been nothing but dismay along with concerns regarding fraudulent activities. Be extremely cautious, or better yet, look for an honest platform for your needs.

  39. Albertnab说道:

    п»їbest mexican online pharmacies: buying prescription drugs in mexico – reputable mexican pharmacies online

  40. Tporoy说道:

    cialis soft tabs pills seize – viagra super active online port viagra oral jelly online hour

  41. Manuelloupe说道:

    mexican pharmacy [url=http://mexicanpharmacy1st.com/#]mexican online pharmacies prescription drugs[/url] mexican mail order pharmacies

  42. Williamlyday说道:

    http://mexicanpharmacy1st.com/# mexico drug stores pharmacies

  43. scam说道:

    I strongly recommend stay away from this site. My personal experience with it was nothing but frustration and suspicion of deceptive behavior. Exercise extreme caution, or even better, seek out an honest platform to fulfill your requirements.

  44. Williamlyday说道:

    https://mexicanpharmacy1st.shop/# mexican online pharmacies prescription drugs

  45. Robertswela说道:

    best mexican online pharmacies: mexican online pharmacies prescription drugs – purple pharmacy mexico price list

  46. scam说道:

    I highly advise steer clear of this site. My personal experience with it has been purely disappointment along with suspicion of deceptive behavior. Proceed with extreme caution, or better yet, find an honest platform to fulfill your requirements.

  47. 급전说道:

    Your writing is engaging and informative. Thank you for sharing your expertise.급전

  48. ラブドール说道:

    Upon getting been whitelisted in our program, you won’t maybe get blocked once more by ourオナホ 高級 firewall! Ban lifts also just take influence automatically. We sincerely apologize for this poor knowledge.

  49. Manuelloupe说道:

    pharmacies in mexico that ship to usa mexican rx online mexican online pharmacies prescription drugs

发表回复

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