xunmi_love 发表于 2007-12-17 11:06

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

要查詢一個字段在多個列中的位置的時候能用OR的關係嗎?

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

這樣可以嗎?

XieLi 发表于 2007-12-17 11:15

当然可以用OR

xunmi_love 发表于 2007-12-17 11:26

那我的這一段代碼那裡出錯了呢!?、?
能幫我解一下嗎?

XieLi 发表于 2007-12-17 11:31

你是在查询分析器里面执行,还是别的地方!

xunmi_love 发表于 2007-12-17 11:37

在查询分析器里面执行  時不行
在asp裡面執行時也不行

cxfj是一個變量!。

[[italic] 本帖最后由 xunmi_love 于 2007-12-17 11:38 编辑 [/italic]]

xunmi_love 发表于 2007-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
                   %>

XieLi 发表于 2007-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里面我就不知道啦!

xunmi_love 发表于 2007-12-17 11:45

那先謝謝你~

我主要是放到ASP當中去的!剛學,好東西都不懂!

XieLi 发表于 2007-12-17 11:50

他提示你什么错啊!

xunmi_love 发表于 2007-12-17 13:54

ODBC不支持!!!

页: [1]

编程论坛