English 中文(简体)
采用我sql的载体功能检索的复杂数据
原标题:complex data retrieve using string functions in mysql
  • 时间:2012-04-11 05:25:54
  •  标签:
  • 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 } 

如你能看到,有些领域可能出现过错,或含有与一些地方的过错。

我将如何安排 s语,在括号中填满编号? 例如,我要从第二个例子中看到“264596,264583,264590”等。

最佳回答

我没有时间来对此加以规范,但你希望利用这些联系作为指南而建立一种职能:

缩略语:

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;
问题回答

暂无回答




相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...

热门标签