在jsp中与数据库相连用的是值连 想起到查询功能,用的是预处理 sql语句是 select * from tblcategory,tblproduce where tblcategory.category=tblproduce.category and name like '%?% ' 这样会报错 为什么阿?? 这种方式不行 拿什么可以做到模糊查询呢 请哪位高手指导以下阿阿
发表于:2007-08-20 08:50:121楼 得分:0
like this
preparedstatement cmd = cn.preparestatement( "select * from tblcategory,tblproduce where tblcategory.category=tblproduce.category and name ? "); cmd.setstring(1, "%m% ");
发表于:2007-08-20 09:11:102楼 得分:0
select * from tblcategory,tblproduce where tblcategory.category=tblproduce.category and name like '%?% ' 1这条sql语句从效率上不是太高.多表关联尽量用inner join 2sql中的name字段表达不明确,sql无法知道此name是tblcategory的 还是tblproduce的 整理后如下: select * from tblcategory inner join tblproduce on tblcategory.category=tblproduce.category where tblcategory.name like '%?% '