获取json格式中属性—sql
set @str = '{"barcode":"6948043429812","brandCode":"M140","canSale":1,"categoryCode":"91050101","chineseName":"悠雅花漾水之源唇膏1.8g","companyId":0,"currentPage":0,"id":0,"isDeleted":0,"isGeneral":1,"isInvoice":1,"isVatInvoice":1,"isVoice":0,"itemsPerPage":0,"mainUnitCode":"PC","merchantCode":"","productCode":"91050101","saleprice":19.90,"serialAttributeList":[{"name":"顏色","value":"2#漿果紅"},{"name":"規格","value":"11ML"}],"startItem":0,"storeCode":"","thirdMerchantProductCode":"20002440","type":1,"typeOfProduct":2}';
set @subKey = '"thirdMerchantProductCode":';
select substring(substring(@str,LOCATE(@subKey,@str)),LENGTH(@subKey)+2,LOCATE(',',substring(@str,LOCATE(@subKey,@str)))-LENGTH(@subKey)-3) from product.merchant_product mp
where @str like CONCAT('%"',mp.chinese_name,'"%') and mp.chinese_name = '悠雅花漾水之源唇膏1.8g' LIMIT 1;
?
#對應updte語句
update?
product.merchant_product mp
inner join product.product_sap sap on mp.chinese_name = sap.product_name
set mp.third_merchant_product_code = substring(substring(sap.json_string,LOCATE(@subKey,sap.json_string)),LENGTH(@subKey)+2,LOCATE(',',substring(sap.json_string,LOCATE(@subKey,sap.json_string)))-LENGTH(@subKey)-3)
where mp.is_deleted=0 and mp.third_merchant_product_code is null ;
總結
以上是生活随笔為你收集整理的获取json格式中属性—sql的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 网络爬虫:商品比价定向爬虫
- 下一篇: 关于Behavior的使用方法