select where语句请教!

来源:百度知道 编辑:UC知道 时间:2024/05/15 01:27:16
name=request("name")
xuehao=request("xuehao")
sql="select distinct * from " & sheet & " where 学号 like '%" &xuehao& "%' and 姓名 like '%" &name& "%'"
sql=sql & " order by 学号 "

这里是两个条件查询!但用的是like查询!即相似查询!
我要怎么改才能实现两个条件必需完全符号才可以查询到!否则为空!
我试着将这个like改为"="号,但是好像什么都查不到了。。

另外学号和姓名字段都是文本的,这需不需要将学号字段改为数值型字段呀?

谢谢
忘了说明环境了!

我用的是asp+acess的!

程序目前是正常运作的!主要是想改这个模糊查询为精确查询!

name=request("name")
xuehao=request("xuehao")
sql="select distinct * from " & sheet & " where 学号 = " &xuehao& " and 姓名 = '" &name& "'"
sql=sql & " order by 学号 "

学号字段为数字型

改成
sql="select distinct * from " & sheet & " where 学号 like '" &xuehao& "' and 姓名 like '" &name& "'"
试试

name=request("name")
xuehao=request("xuehao")
sql="select distinct * from " & sheet & " where 学号 = '" &xuehao& "' and 姓名 = '" &name& "'"
sql=sql & " order by 学号 "