解决方案 »

  1.   

    select a.*,b*,c.*  from yiche a  left join value b on a.modelid = b.modelid left join param c on b.paramid = c.paramid
      

  2.   

    我试过SQL语句查询 量太大了 直接就溢出了   要用程序去弄
     是现查 parentid 然后再查parentid下的modelid ,最后比较其他的属性,找出相同的
      

  3.   

    你还是把问题描述清楚,我看了一下,拿纸写了一下,结果发现没看懂。“param表中有4个属性paramid分别对应的是1 ,4,78,256 每个modelid都有这四个属性,”什么意思啊
      

  4.   

    这是个属性对应的是1=出厂价格  4=排量   78=出厂日期   256=最大价格 每个modelid都有这四个属性  最后的判断也是根据这四个属性来判断相同的
      

  5.   

    哪张表数据大?
    第一张表 几万条数据
    那你想全查出来吗? 
    先distinct一下,一段一段取呢,400一取这样。
      

  6.   

    好吧我错了 我粘下代码吧  
    public static void main(String[] args) throws SQLException {
    Set<CarInfos> set = new TreeSet<CarInfos>();
    DatabaseOperator dbop = new DatabaseOperator();
    FenYeQuery fyq = new FenYeQuery("select id, paramid, modelid, value from tbl_car_param_value_yiche where paramid in (1, 4, 75, 287) ");
    long index = 1;
    CarInfos carInfos = null;
    String insertSql = null;
    ResultSet rs = null;

    while(true) {
    rs = fyq.query();
    if(rs.next()) {
    rs.previous();
    }
    else {
    break;
    }

    while(rs.next()) {
    carInfos = new CarInfos();
    carInfos.setId(rs.getLong("id"));
    carInfos.setModelid(rs.getLong("modelid"));
    carInfos.setParamid(rs.getLong("paramid"));
    carInfos.setValue(rs.getString("value"));

    if(set.contains(carInfos)) {
    insertSql = "insert into tbl_car_param_value_yiche_bak(" +
    "id, modelid, paramid, value) values(" + 
    carInfos.getId() + "," + carInfos.getModelid() + "," + 
    carInfos.getParamid() + ", '" + carInfos.getValue() + "');";
    dbop.executeSql(insertSql);
    }
    else {
    set.add(carInfos);
    System.out.println("Add Success! Index:" + index++);
    }
    }
    }

    System.out.println("Success!");
    }
    }
      

  7.   

    我在另一个方法里重写了equals 方 法  后来才知道 比的是hashcode。 效率特别低。。