优秀购物网站建设,专做立体化的网站,棋牌app制作教程,php代理ip访问网站今天自己出了一道题差点把自己难住…… 题目是这样的#xff1a; 已知有三条查询的sql语句#xff0c;小明不小心写一块了#xff0c;你帮他拆分开。sql语句为#xff1a;select * from books where bid 1 select * from cate where name ‘java’ select title fr…今天自己出了一道题差点把自己难住…… 题目是这样的 已知有三条查询的sql语句小明不小心写一块了你帮他拆分开。sql语句为select * from books where bid 1 select * from cate where name ‘java’ select title from books where id 2002
下面是实现代码
public static void testUpS() {String sql select * from books where bid 1 select * from cate where name java select title from books where id 2002 ;// 先查找第二个select的位置int i1 sql.indexOf(select, 1);int i2 sql.lastIndexOf(select);// 给select前面插入一个-便于后面截取StringBuffer sb new StringBuffer(sql);sb.insert(i1, -);sb.insert(i2,-);String [] str (sb.toString()).split(-);for (String ss : str) {System.out.println(ss);}}细细一看不是很难的。 欢迎关注公众号雄雄的小课堂哈哈哈~