我整个上午都花在这上面,我绝对难过。
我有一个mysql表,其中一个列填充如下:
arrOpt['']={price:564.3,msrp:'779', d:'Width: 25"" |Height: 54"" |Weight: 33lbs',sku:6886939,ac:'260.00',ship:'221.95',cShip:'0.00',img:'503-13-35.jpg',imgT:'',oImg:'',shipW:'0',leadL:'7',leadU:'10',partNo:'503-13-35',invChk:'33rd',mfrStk:'',stkShip:'1',bo:'',desc:'',osum:'',upc:'702404269082',packQty:1,ship_via:'FreeTrk',freightUpgradeLvl1:'25.00',site:'home',clearancePrice:'0.00',shipTimeCutOff:'', shipTime:'Mar 12th - Mar 15th'} "
也有可能是这样的:
arrOpt['264596']={price:30.25,msrp:'46.1519', d:'Length: 126"" |Height: 8.5""',sku:7356623,ac:'12.75',ship:'6.00',cShip:'0.00',img:'151_celery.jpg',imgT:'',oImg:'',shipW:'3',leadL:'7',leadU:'14',partNo:'151 Blue',invChk:'31st',mfrStk:'20',stkShip:'1',bo:'',desc:'',osum:'Blue',upc:'',packQty:1,ship_via:'Ground',freightUpgradeLvl1:'0.00',site:'baby',clearancePrice:'0.00',shipTimeCutOff:'', shipTime:'Mar 12th - Mar 19th'};arrOpt['264583']={price:30.25,msrp:'46.1519', d:'Length: 126"" |Height: 8.5""',sku:7356624,ac:'12.75',ship:'6.00',cShip:'0.00',img:'151_celery.jpg',imgT:'',oImg:'',shipW:'4',leadL:'7',leadU:'14',partNo:'151 Celery',invChk:'31st',mfrStk:'20',stkShip:'1',bo:'',desc:'',osum:'Celery',upc:'',packQty:1,ship_via:'Ground',freightUpgradeLvl1:'0.00',site:'baby',clearancePrice:'0.00',shipTimeCutOff:'', shipTime:'Mar 12th - Mar 19th'};arrOpt['264590']={price:30.25,msrp:'46.1519', d:'Length: 126"" |Height: 8.5""',sku:7356625,ac:'12.75',ship:'6.00',cShip:'0.00',img:'151_celery.jpg',imgT:'',oImg:'',shipW:'4',leadL:'7',leadU:'14',partNo:'151 Chambray',invChk:'31st',mfrStk:'7',stkShip:'1',bo:'',desc:'',osum:'Chambray',upc:'',packQty:1,ship_via:'Ground',freightUpgradeLvl1:'0.00',site:'baby',clearancePrice:'0.00',shipTimeCutOff:'', shipTime:'Mar 12th - Mar 19th'};arrOpt['264597']={price:30.25,msrp:'46.1519', d:'Length: 126"" |Height: 8.5""',sku:7356626,ac:'12.75',ship:'6.00',cShip:'0.00',img:'151_celery.jpg',imgT:'',oImg:'',shipW:'4',leadL:'7',leadU:'14',partNo:'151 Ecru',invChk:'31st',mfrStk:'30',stkShip:'1',bo:'',desc:'',osum:'Ecru',upc:'',packQty:1,ship_via:'Ground',freightUpgradeLvl1:'0.00',site:'baby',clearancePrice:'0.00',shipTimeCutOff:'', shipTime:'Mar 12th - Mar 19th'};arrOpt['264601']={price:30.25,msrp:'46.1519', d:'Length: 126"" |Height: 8.5""',sku:7356627,ac:'12.75',ship:'6.00',cShip:'0.00',img:'151_celery.jpg',imgT:'',oImg:'',shipW:'4',leadL:'7',leadU:'14',partNo:'151 Lavender',invChk:'31st',mfrStk:'25',stkShip:'1',bo:'',desc:'',osum:'Lavender',upc:'',packQty:1,ship_via:'Ground',freightUpgradeLvl1:'0.00',site:'baby',clearancePrice:'0.00',shipTimeCutOff:'', shipTime:'Mar 12th - Mar 19th'};arrOpt['264603']={price:30.25,msrp:'46.1519', d:'Length: 126"" |Height: 8.5""',sku:7356628,ac:'12.75',ship:'6.00',cShip:'0.00',img:'151_celery.jpg',imgT:'',oImg:'',shipW:'4',leadL:'7',leadU:'14',partNo:'151 Maize',invChk:'31st',mfrStk:'20',stkShip:'1',bo:'',desc:'',osum:'Maize',upc:'',packQty:1,ship_via:'Ground',freightUpgradeLvl1:'0.00',site:'baby',clearancePrice:'0.00',shipTimeCutOff:'', shipTime:'Mar 12th - Mar 19th'};arrOpt['264608']={price:30.25,msrp:'46.1519', d:'Length: 126"" |Height: 8.5""',sku:7356629,ac:'12.75',ship:'6.00',cShip:'0.00',img:'151_celery.jpg',imgT:'',oImg:'',shipW:'4',leadL:'7',leadU:'14',partNo:'151 Pink',invChk:'31st',mfrStk:'20',stkShip:'1',bo:'',desc:'',osum:'Pink',upc:'',packQty:1,ship_via:'Ground',freightUpgradeLvl1:'0.00',site:'baby',clearancePrice:'0.00',shipTimeCutOff:'', shipTime:'Mar 12th - Mar 19th'};arrOpt['264616']={price:30.25,msrp:'46.1519', d:'Length: 126"" |Height: 8.5""',sku:7356630,ac:'12.75',ship:'6.00',cShip:'0.00',img:'151_celery.jpg',imgT:'',oImg:'',shipW:'4',leadL:'7',leadU:'14',partNo:'151 White',invChk:'31st',mfrStk:'50',stkShip:'1',bo:'',desc:'',osum:'White',upc:'',packQty:1,ship_via:'Ground',freightUpgradeLvl1:'0.00',site:'baby',clearancePrice:'0.00',shipTimeCutOff:'', shipTime:'Mar 12th - Mar 19th'}
正如您所看到的,arrOpt可以是空白的字段,也可以包含多个带有数字的arrOpt字段。
如何构造sql语句以获取括号内的数字?例如,我希望能够从第二个例子中获取“264596,264583,264590”等。
答案 0 :(得分:0)
我没有时间对此进行编码,但您希望使用这些链接作为指南创建一个函数:
伪代码:
Pos = 0;
OutString = "";
Length = Len(InString);
WHILE LocationOf "arrOpt['" in right(InString,Length - Pos) > 0
Start = Location + 8;
End = Locationof "'" in right(InString,Length - Start + 1);
OutString = concatenate(OutString,",",Mid(InString,Start,End);
Pos = End + 1;
EndWhile
OutString = right(OutString,Len(OutString) - 1;
return OutString;