易截截图软件、单文件、免安装、纯绿色、仅160KB

关于mysql模糊查询问题,急!急!急!

最近,小弟用到mysql模糊查询时碰到了一个难以解决的问题,在网上找了很多了资料,也没能解决,希望在这里碰到高手,帮小弟度过难关,小弟我感激涕零~~~
好的,看下面这段代码吧:
SQL code:

mysql> use mingxuan;
Database changed
mysql> select count(id) from product where ptype like '%联想%' and bid=(
-> select id from brand where bname='联想' and cid=(
-> select id from category where id=4
-> )
-> );
+-----------+
| count(id) |
+-----------+
| 2 |
+-----------+
1 row in set (0.00 sec)


在mysql里面可以用这个sql语句进行模糊查询,但是到了Java程序里面用con.prepareStatement(sql);问题就来了
代码如下:
Java code:

String sql = "select count(id) from product "
+ "where ptype like ? and bid=( "
+ "select id from brand where bname=? and cid=( "
+ "select id from category where id=?));";
con = DBUtil.getConnect();
try {
ps = con.prepareStatement(sql);
ps.setString(1, "%" + type + "%");
ps.setString(2, bname);
ps.setInt(3, cid);
rs = ps.executeQuery();
if (rs.next()) {


相关问答:

从mysql读图片路径但是无法显示

大家帮我看下吧,本来数据库没有东西,能显示没有东西的信息,但是我添加了一条内容后,字没了,但是图片也无法显示,红叉叉也没有,怎么回事啊?
PHP code:

<?php
$str="select * from product wh ......

mysql中文乱码 - C/C++ / C++ 语言

mysql数据库的编码格式是utf8
在c++程序中使用C API直接连接mysql数据库,把中文保存到mysql数据库中,中午变成乱码
使用mysql的load命令导入文本文件,无论文本文件是ANSI还是utf8编码,都是乱码
请问上面两个问 ......

MySQL Errno : 1064 PHPCMS2008问题

PHPCMS企业黄页2008分页问题
我用以下方式求平均数
  {get sql="SELECT DISTINCT c.*,
(select round(avg(sort1)) from `phpcms_yp_dp` where userid=c.userid) avgsort1,
(select round(avg(avgp ......

请教:嵌入式系统安装MySQL数据库的问题

今天老大布置个任务,要我在我们的产品中安装一个MYSQL数据库,要求是软件占用空间不能超过5M。
在网上找了好久也没有找到关于嵌入式系统中MySQL数据库的资料,有的也只是简单提一下。
现特向各位请教以下问题:
......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号