在access資料庫中if
❶ ACCESS資料庫中 if判斷要怎麼寫
如果是在access資料庫的窗體里寫代碼,if (expr) then *** else *** endif 語句是可以用的。如果是sql語句里可以用IIf(expr, truepart, falsepart),如果不行,我想應該是你的表達式有問題吧。
❷ ACCESS 怎麼實現 類似 SQL中 if 。。。then。。語句的功能
SQL 中可以用觸發器實現這個功能
❸ ACCESS 的 查詢里可以寫 if 嗎 比如 如果等於10 輸出一個欄位 就等於 AA
^_^
有80分,好好回答一下. 哈哈~~
資料庫名:test.mdb
表名:table1
欄位名:a1,a2,a3
查詢直接用
sql="select * from table1"
即可.
關鍵是如何處理從表單傳遞過來的數據.
假如從表單傳遞的查詢關鍵字為"KeyWords":
<input type="text" name="KeyWords" size="20" value="">
那麼在後台對KeyWords處理時,可以利用InStr()函數檢查在rs("a1"),rs("a2")和rs("a3")中是否含有KeyWords,如果包含了要查詢的KeyWords,則顯示該條記錄.即:
if (InStr(rs("a1"),request("KeyWords"))<>0) or (InStr(rs("a2"),request("KeyWords"))<>0) or (InStr(rs("a3"),request("KeyWords"))<>0) then 顯示該記錄的值
思路已經很清楚了.
樓主說要詳細的代碼,那麼給出一個完整的asp程序,請樓主調試運行:
(資料庫結構如上所述)
search.asp
<%
'連接資料庫
set conn=server.createobject("adodb.connection")
provider="provider=microsoft.jet.oledb.4.0;"
DBPath ="data source=" & Server.MapPath("test.mdb")
conn.Open provider & DBPath
%>
<html>
<head><title></title></head>
<body>
<div align="center">
<form method="POST" action="search.asp" name="searchform">
<table width="380" align="center" border="0">
<tr>
<td>輸入查詢關鍵字:</td>
<td><input type="text" name="KeyWords" size="20" value=""></td>
<td><input type="submit" border="0" value="查 詢" name="CX"></td>
</table>
</form>
<table border="1" width="560">
<tr><td><b>查詢結果:</b></td></tr>
<%
total=0
sql="select * from table1"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1
%>
<% if request("KeyWords")="" then %>
<tr><td>沒有您要查詢的內容。</td></tr>
<%
else
for i = 1 to rs.recordcount
if (InStr(rs("a1"),request("KeyWords"))<>0) or (InStr(rs("a2"),request("KeyWords"))<>0) or (InStr(rs("a3"),request("KeyWords"))<>0) then
total=total+1
%>
<tr><td><%=rs("a1")%>,<%=rs("a2")%>,<%=rs("a3")%></td></tr>
<%
end if
rs.movenext
next
end if
%>
<tr><td align="center">一共搜索到<%=total%>條記錄!</td></tr>
<%
rs.close
set rs=nothing
%>
</table>
</div>
</body></html>
祝你成功!
❹ access中if怎樣讓兩個條件同時成立,求表達式
1、可以使用and來連接兩個邏輯表達式。
2、示例:
if (a>10 and a<100) then ...
這樣就能保證在a>中雀10成立並且a<100也成立的情況下才執行...
3、Microsoft Office Access是微軟把資料庫引擎的圖形用戶界面和軟體開發賣此早工具結合在一起的一個資料庫管理系統。它是微軟OFFICE的一個成員,在包括專業版和更高版本的office版本裡面被單獨出售。2012年12月4日,最新扒寬的微軟Office Access 2013在微軟Office 2013里發布,微軟Office Access 2010 是前一個版本。