select * from table where group_name in ('"' + replace(tmp,',','","') + '"')
不同的数据库replace函数不同

解决方案 »

  1.   

    这就和具体的数据库有关了
    因为'是特殊字符
    select * from table where group_name in (''''+replace(tmp,',',''',''') + '''')
      

  2.   


    这种写法和你上面的写法倒是不出错,但查询不到记录。我用的是mysql。select * from t_group_list where group_name in( replace("A_VIP,B_VIP", "," ,"\",\""));
      

  3.   

    不要这样用
    把replace换成应用程序的函数,把sql拼起来
    aaa=replace("A_VIP,B_VIP", "," ,"\",\"");
    "select * from t_group_list where group_name in('"+aaa+"');"
    再执行
      

  4.   

    已经解决了String destGroupName = req.getParameter("selectGroupName");
    System.out.println(destGroupName); //destGroupName如"AB,CD"的格式String[] splitStr = destGroupName.split(",");
    StringBuffer whereIN = new StringBuffer();
    for(int i=0; i<splitStr.length; i++)
    {
       whereIN.append("\"" + splitStr[i] +  "\"").append(",");

    }
    //去掉最后一个,号
    whereIN = whereIN.deleteCharAt(whereIN.lastIndexOf(","));多谢 192168001001(汉族程序员) !