用java向sql写语句;其中id是主键,还有就是输入时间的字段;我当每次输入相同ID时自动更新该条记录;在java 中如何写这条判断语句。大家最好把语句都写出来,不要提方案。我是新手,需要大家的sql语句

解决方案 »

  1.   

    insert之前先select,如果存在记录就update,否则就insert
      

  2.   

    update table set date='"+date+"' where id='"+id+"'; 
      

  3.   

    输入的id 与sql中id 相同如何写判断语句where id怎么写
      

  4.   


    update tableName set date='"+date+"',更新的其他字段 where id = 输入的id;
      

  5.   

    select count(*) from table where id=?
    int count=查询结果,
    if(count>0){
        update table set date=? where id=?
    }
    else{
         insert table values(id,date)
    }