标题:jdbc中sql语句的疑惑
取消只看楼主
小程序员
Rank: 2
等 级:论坛游民
帖 子:41
专家分:16
注 册:2010-3-8
结帖率:50%
已结贴  问题点数:10 回复次数:0 
jdbc中sql语句的疑惑
(1)用jdbc连接数据库之后。写一条语句发送给数据库查询,代码是这样的
String sql="select * from news where id="+id;
ResultSet rs=conn.executeQuery(sql);
为什么不是:String sql="select * from news where id=id;"id要放到引号外面去呢?
(2)同上:ResultSet rsTmp=conn.executeQuery("select count(id) as countid from news");
news表里面的列只有id、title、content、author、keywords、times。并没有countid,查询的功能跟具体结果是什么?

谢谢各位用心回答我的疑问。不胜感激。。。。

搜索更多相关主题的帖子: jdbc sql 语句 
2010-11-03 20:45



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-324893-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 2.306585 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved