122
123|254|
258|36958|
147
125487|369854|
12574
125487|2569894|4587545|58475|

解决方案 »

  1.   

    目前数据库里这样两字段上班                001
    迟到|早退|休假      a1|a2|a3
    我现在想实现  
      
       上班-001
       迟到-a1,早退-a2,休假-a3
    这样的数据怎么合并??
      

  2.   

    只供参考,写得不好的地方还忘见谅
    ------------------------------------/**
     * project_name: Test
     * package_name: netsource
     * package_declaration: package netsource;
     * filename: DateOpposite.java
     * author: yuhaiming
     * date: 2007-11-14
     */
    /**
     * 目前数据库里这样两字段 

    上班                                 001 
    迟到 ¦早退 ¦休假             a1 ¦a2 ¦a3 


    我现在想实现     
        
          上班-001 
          迟到-a1,早退-a2,休假-a3 


    这样的数据怎么合并??
     */
    package netsource;
    import java.io.*;
    public class DateOpposite {

    public static void disposal(String strvalue1,String strvalue2){ String strresult = "";
    int count1 =-1,count2=-1;
    while((count1 =strvalue1.indexOf("¦"))>0&&(count2 =strvalue2.indexOf("¦"))>0){
    strresult += strvalue1.substring(0,count1).trim()+"-"+strvalue2.substring(0,count2).trim()+"&";
    strvalue1 = strvalue1.substring(count1+1);
    strvalue2 = strvalue2.substring(count2+1); }
    strresult += strvalue1+"-"+strvalue2;
    String[] result = strresult.split("&");
    display(result);
    }
    public static void display(String[] result){
    for(int i=0;i<result.length;i++){
    System.out.println(result[i]);
    }

    }
    /**
     * @param args
     */
    public static void main(String[] args) {
    // TODO Auto-generated method stub
    String strvalue1 = "迟到 ¦早退 ¦休假";//从数据库取值,这里为了方便直接赋值了
    String strvalue2 = "a1 ¦a2 ¦a3";//从数据库取值,这里为了方便直接赋值了
    disposal(strvalue1,strvalue2);
    }}
      

  3.   

    晕....不用这么麻烦吧.....
    public class test {
    public test() {
    String a = "123|234|345";
    String b[] = a.split("|");
    for(String c:b)
    System.out.println(c);
    }
    public static void main(String[] args) {
    new test();
    }
    }
    可以招这样的思路做
      

  4.   

    ...........程序写错了....失误啊......
    上面的 a.split("|")应该是a.split("\\|");
    忘了转义字符了....
      

  5.   

    目前数据库里这样两字段 上班                                 001 
    迟到 ¦早退 ¦休假             a1 ¦a2 ¦a3 
    我现在想实现     
        
          上班-001 
          迟到-a1,早退-a2,休假-a3 
    这样的数据怎么合并??
    select t.上班 || '-' || t.001 from table t