sqlserver模糊查询语句

select * from educate as e where name like '% str %' 这样写有什么错吗

其中str是传递进来的字符串
select e from educate as e where e.name like '% str %' 这样写有什么错吗

str 是传递进来的字符串

你这条语句的意思是:查找name字段中包含字符str的值,如果str是要用户传进来话,需要用sql拼接技术。
String str="jack";
String sql=" select e from educate as e where e.name like '% "+ str +" %' ";
ps.preparedStatement(sql);
应该这么写才对。
温馨提示:答案为网友推荐,仅供参考
第1个回答  2012-07-31
select e.* from educate as e where e.name like '%' +str +'%'
第2个回答  2020-03-04

数据库模糊查询

第3个回答  2012-07-31
你是要拼接sql?程序里写的还是数据库里面?str两边有空格