读取记录
按startno排序
如果(上一条记录的endno)+1 = (本记录的startno) 并且type相同则
newstartno = (上一记录的startno);newendno =(本记录的endno)是这个意思吧?

解决方案 »

  1.   

    表1里面有这样的记录
    startno endno type
    1         5    1
    6         10   1(与上一条记录是连续的)
    21        25   1
    31        40   2
    41        50   2(与上一条记录连续的)
    51        60   3(type不同与上一条记录不连续的)
    ...我想查询出来显示的时候变成
    startno endno type
    1        10    1
    21       25    1
    31       50    2
    51        60   3
    就是将type相同值并且是连号码的两条或多条记录的合并
      

  2.   

    用php数组就不难解决,把type定为一位下标
    对同一维的数组进行比较合并(取合并的数组的最大最小值)就可以了
      

  3.   

    唠叨大哥,snmr_com(麒麟厍人) 教教小弟
      

  4.   

    if ($array[$i]["startno"]-$array[$i-1]["endno"] === 1) {……} 诸如此类,其实应该还有其他更简单的方法,不过这个思路最简单
      

  5.   

    $query="select *  from tb_sendbill_x where fd_senbx_senbzid= '$senbzid' order by fd_senbx_type,fd_senbx_start";
    $db->query($query);
    while($db->next_record()){
    $i++;
    $type = $db->f(fd_senbx_type);
    $startno     = $db->f(fd_senbx_start);
    $endno     = $db->f(fd_senbx_end);

    if($i==1){
    $new_voucherid[]    = $type;
    $new_startno[]     = $startno;  
    $new_endno[]     = $endno;   
    }else{
      if( end($new_endno) + 1==$startno && end($new_type)==$type){
    array_pop($new_endno);
    $new_endno[]  = $endno[$i] ;
      }else{
             $new_voucherid[]    = $type;
    $new_startno[]     = $startno;  
    $new_endno[]     = $endno;   
      }
    }       
    }
    不知这样是否对?
      

  6.   

    实践是检验真理的唯一标准,run it看你写代码就知道你的水平比我高,思路有了,后面就你努力吧!