当前位置: 技术问答>java相关
请大虾指点一二 网上书店 书籍查询sql 语句
来源: 互联网 发布时间:2015-09-08
本文导语: String author=request.getParameter("author").trim(); String bookname=request.getParameter("bookname").trim(); String bookSelect=""; String authorSelect=""; if(bookname.compareTo("")!=0){ nameSelect="bookname='"+bookname+"'";} if(author.compareTo("")!=0) { authorSelect="auth...
String author=request.getParameter("author").trim();
String bookname=request.getParameter("bookname").trim();
String bookSelect="";
String authorSelect="";
if(bookname.compareTo("")!=0){
nameSelect="bookname='"+bookname+"'";}
if(author.compareTo("")!=0) {
authorSelect="author='"+author+"'";}
byte[] tmpbyte=bookSelect.getBytes("ISO8859_1");
bookSelect=new String(tmpbyte);
tmpbyte=authorSelect.getBytes("ISO8859_1");
authorSelect=new String(tmpbyte);
if(authorSelect.compareTo("")!=0&&nameSelect.compareTo("")!=0) nameSelect="and"+nameSelect;
String sql="select pid from book where";
sql=sql+authorSelect+nameSelect+"order by pid desc";
String bookname=request.getParameter("bookname").trim();
String bookSelect="";
String authorSelect="";
if(bookname.compareTo("")!=0){
nameSelect="bookname='"+bookname+"'";}
if(author.compareTo("")!=0) {
authorSelect="author='"+author+"'";}
byte[] tmpbyte=bookSelect.getBytes("ISO8859_1");
bookSelect=new String(tmpbyte);
tmpbyte=authorSelect.getBytes("ISO8859_1");
authorSelect=new String(tmpbyte);
if(authorSelect.compareTo("")!=0&&nameSelect.compareTo("")!=0) nameSelect="and"+nameSelect;
String sql="select pid from book where";
sql=sql+authorSelect+nameSelect+"order by pid desc";
|
String author = new String(request.getParameter("author").trim().getBytes("ISO8859_1"), "GB2312");
String bookname=new String(request.getParameter("bookname").trim().getBytes("ISO8859_1"), "GB2312");
String authSQL = null;
String nameSQL = null;
boolean flag=true;
if(author == null || author.equals("")) {
authSQL = "";
flag=false;
} else {
authSQL = "author='" + author + "'";
flag=true;
}
if(bookname == null || bookname.equals("")) {
bookname = "";
} else {
if(flag) bookname = "and bookname='" + bookname + "'";
else bookname = "bookname='" + bookname + "'";
}
String sql = "select pid from book where";
sql = sql + authSQL + nameSQL;
String bookname=new String(request.getParameter("bookname").trim().getBytes("ISO8859_1"), "GB2312");
String authSQL = null;
String nameSQL = null;
boolean flag=true;
if(author == null || author.equals("")) {
authSQL = "";
flag=false;
} else {
authSQL = "author='" + author + "'";
flag=true;
}
if(bookname == null || bookname.equals("")) {
bookname = "";
} else {
if(flag) bookname = "and bookname='" + bookname + "'";
else bookname = "bookname='" + bookname + "'";
}
String sql = "select pid from book where";
sql = sql + authSQL + nameSQL;
您可能感兴趣的文章:
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。