将string数组转化为sql的in条件
来源:互联网 发布:淘宝怎么发安能快递 编辑:程序博客网 时间:2024/06/06 03:52
例如:我想将String[] str = {"4","5","6"}转化为“‘4’,‘5’,‘6’”字符串。这样我就可以用sql查询:select * from tableName id in (字符串)了。
项目中实现的源码如下:
StringBuffer idsStr = new StringBuffer();for (int i = 0; i < ids.length; i++) {if (i > 0) {idsStr.append(",");}idsStr.append("'").append(ids[i]).append("'");}
我自己想到的另一种方式实现如下:
public static String stringArray2Strin(String[] str) {StringBuffer sb = new StringBuffer();for (int i = 0; i < str.length; i++) {sb.append("'").append(str[i]).append("'").append(",");}return sb.toString().substring(0, sb.length() - 1);}public static void main(String[] args) {String[] str = { "4", "5", "6" };System.out.println(ItemGroupService.stringArray2String(str));}
0 0
- 将string数组转化为sql的in条件
- 将string数组转化为sql的in条件用sql查询
- 将String转化为String数组
- 将Byte数组转化为String
- 将Byte数组转化为String
- [转贴]将Byte数组转化为String
- 将Byte数组转化为String
- 将Byte数组转化为String
- 将Byte数组转化为String
- 将Byte数组转化为String
- 将Byte数组转化为String
- 将Byte数组转化为String
- java中如何将char数组转化为String?
- java中如何将char数组转化为String
- JAVA中如何将char数组转化为String
- java中如何将char数组转化为String?
- 将byte数组转化为string,及其还原。
- 将List转化为数组的若干问题
- 雷军:最崇拜的创业公司是阿里
- JavaScript Date的原型方法扩展
- IE11 中的兼容性更改
- 从文章劈腿深思社会化媒体
- Integer和类实现问题和重写++问题
- 将string数组转化为sql的in条件
- 怎么查看Java平台环境?
- 论文读书笔记-improving word representations via global context and multiple word prototypes
- 决策树--从原理到实现
- PHP UNICODE 编码转换(JS的encodeURIComponent函数 和 PHP的自定义unescape函数)
- 分批次调用ARRAYLIST接口
- 多名高官落马通报提及道德败坏 实为有数个情妇
- Android程序的版本检测与更新
- 游戏服务器之场景范围搜索