主题:  请教:关于SQL在查询语句

xiaojim

职务:普通成员
等级:1
金币:0.0
发贴:27
注册:2002/11/5 16:03:50
#12003/3/12 16:32:23
请教:关于SQL在查询语句中。如在同一表中有多个字段,name add birth等好多个
我现在要查询且每个字段都要用到


select name, add, birth
from user
where name like '%ABC%' or add like '%ABC%'or ....

where 这句要将所有的字段都要像这样写出来么,??有没有简单的方法,



沉默是金

职务:普通成员
等级:6
金币:11.2
发贴:4357
注册:2004/2/18 11:17:25
#22003/3/13 11:15:43
用where的子语句查询喽,你这样太占资源了。
这是我写的,你拿去改一下吧。
<%
dim rs,sql
set rs=Server.CreateObject("ADODB.Recordset")
sql="select * from u_masg where u_type='"&u_type&"'"
if u_ye<>"" or u_ye<>"按行业查询" then
sql=sql & " and u_ye like '%"& u_ye &"%'"
end if
if u_xue<>"0" then
sql=sql & " and u_xue='" & u_xue & "'"
end if
if u_body<>"" then
sql=sql & " and u_title like '%"&u_body&"%' "
end if
if u_time<>"00" then
sql=sql & " and u_time>='" & dateadd("d",-cint(u_time),date()) & "'"
end if
sql=sql & " order by id desc"
rs.open sql,cn,1,1
if rs.recordcount<1 then
response.write "
暂时还没有你要查询的信息
"
else
……
end if
%>


难人一个……

xiaojim

职务:普通成员
等级:1
金币:0.0
发贴:27
注册:2002/11/5 16:03:50
#32003/3/14 11:25:30
谢过~