注册 登录
编程论坛 SQL Server论坛

sql語句不能用or的關係嗎?

xunmi_love 发布于 2007-12-17 11:06, 1095 次点击
要查詢一個字段在多個列中的位置的時候能用OR的關係嗎?

比如:
select * from tellist
 where bumen="&cxfj&"
 or danwei="&cxfj&"
or name="&cxfj&"
or fenji="&cxfj&"",conn,1,1

這樣可以嗎?
9 回复
#2
XieLi2007-12-17 11:15
当然可以用OR
#3
xunmi_love2007-12-17 11:26
那我的這一段代碼那裡出錯了呢!?、?
能幫我解一下嗎?
#4
XieLi2007-12-17 11:31
你是在查询分析器里面执行,还是别的地方!
#5
xunmi_love2007-12-17 11:37
在查询分析器里面执行  時不行
在asp裡面執行時也不行

cxfj是一個變量!。

[[italic] 本帖最后由 xunmi_love 于 2007-12-17 11:38 编辑 [/italic]]
#6
xunmi_love2007-12-17 11:39
<%
           dim cxfj
           cxfj=1231
           set conn=server.createobject("adodb.connection")
           conn.open"driver={microsoft access driver (*.mdb)};dbq="&server.mappath("data\gonggao.mdb")
           set rs=server.createobject("adodb.recordset")
           rs.open ("select * from tellist where bumen='"&cxfj&"' or danwei='"&cxfj&"' or name='"&cxfj&"' or fenji='"&cxfj&"'"),conn,1,1
           if rs.eof then
           response.write"sorry ! did not find anlything from your key"
           end if
           %>
#7
XieLi2007-12-17 11:43
在查询分析器时面
DELCAR @CXFJ  VARCHAR(10)
SET @CXFJ='ABC'
select * from tellist where bumen=@CXFJ or danwei=@CXFJ  or name=@CXFJ or  fenji=@CXFJ

ASP里面我就不知道啦!
#8
xunmi_love2007-12-17 11:45
那先謝謝你~
我主要是放到ASP當中去的!剛學,好東西都不懂!
#9
XieLi2007-12-17 11:50
他提示你什么错啊!
#10
xunmi_love2007-12-17 13:54
ODBC不支持!!!
1