关于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()) {
相关问答:
请问下哪位仁兄有比较好的备份方案,用什么工具或者用什么方式,小弟借鉴下
直接用MYSQLDUMP备份
OR
用SQLYOG之类的图形化管理工具备份
直接用mysql自带的 mysqldump 就可以了。
http://dev.mysql.com/doc/re ......
String SQL="insert into 学生信息表 values(StudentNumber,StudentName,StudentAge)";其中StudentNumber,StudentName,StudentAge都是变量。这样写不对……到底该咋写啊
万分感谢!
String SQL=&q ......
mysql数据库的编码格式是utf8
在c++程序中使用C API直接连接mysql数据库,把中文保存到mysql数据库中,中午变成乱码
使用mysql的load命令导入文本文件,无论文本文件是ANSI还是utf8编码,都是乱码
请问上面两个问 ......
表
CREATE TABLE `ch1` (
`id` int(10) unsigned zerofill NOT NULL AUTO_INCREMENT,
`no` int(10) unsigned DEFAULT NULL,
`dtime` datetime DEFAULT NULL,
PRIMARY KEY (`id ......
如题。我已经安装了mysqlodbc驱动。
adodc控件属性里面,连接资源,
有
使用DataLink文件
使用ODBC数据资源名称
使用连接字符串
是选择哪个?
然后得步骤是怎么样的?
HTML code:
http://www.connectionst ......