Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Database/JDBC/SQL/JDO/Hibernate  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 求助sql语句
letmesee





发贴: 3
积分: 0
于 2006-04-23 22:59 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
我的问题是想通过字符串匹配达到关键字查询的目的

在access中调试得到
正确查询语句为 select * from aaa where bbb like "*ccc*"

但是我改成 select * from aaa where b like '*ccc*' 放入""之间调试无任何
返回记录
public ResultSet getResult(String query) throws SQLException,
  SystemException {
  Connection con;
  con = DatabaseConnect.getConnection();
  Statement stmt = con.createStatement();
  ResultSet rs = stmt.executeQuery(query);
  return rs;
}

这是我获取记录的函数,如果不考虑其他方法的话,请问这条查询语句该怎么写呢



作者 Re:求助sql语句 [Re:letmesee]
why

問題兒童

总版主


发贴: 4629
积分: 388
于 2006-04-24 00:58 user profilesend a private message to usersend email to whysearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
select * from aaa where bbb like "*ccc*"
select * from aaa where b like '*ccc*'

though this doesn't seem to be the cause.



作者 Re:求助sql语句 [Re:letmesee]
letmesee





发贴: 3
积分: 0
于 2006-04-24 15:47 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
那么这是为什么呢


作者 Re:求助sql语句 [Re:letmesee]
why

問題兒童

总版主


发贴: 4629
积分: 388
于 2006-04-24 20:21 user profilesend a private message to usersend email to whysearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
letmesee wrote:
那么这是为什么呢

閣下提供的資料不足,無從估計

閣下有沒有試過別的SQL statement,能否得到相應的resultset?
print query in getResult and see whether it is correct

其實在M$ Access 也應用 '*ccc*'


why edited on 2006-04-24 20:32


flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923