關于sql語句改寫?
html頁面
<form action="search.asp" method="post">
<tr >
<td colspan="2" align="center"> <input type=text size=12 name="keyword">
<br>
<select name="AreaSearch">
<option value=1>標題</option>
<option value=2>內容</option>
</select>
<br>
<select name="DateSearch">
<option value=all>所有時間</option>
<option value=1>昨天以來</option>
<option value=3>3 天以來</option>
<option value=7>7 天以來</option>
<option value=15>15天以來</option>
<option value=30>30天以來</option>
<option value=60>60天以來</option>
<option value=90>90天以來</option>
</select><br>
<input type=submit value="搜索" name="submit">
</td>
</tr>
</form>
select.asp頁面
<%
keyword=trim(request("keyword"))
dim searchday
if request("DateSearch")="all" then
searchDay=""
else
searchDay=" DATEDIFF('d',addtime,Now()) < "&request("DateSearch")&" and "
end if
dim pagecount,page,Spage,Epage,recordcount,i
page = request.querystring("page")
if page = "" or IsNull(page) then page = 1
if not IsNumeric(page) then page = 1
page = Cint(page)
set rs = server.CreateObject ("Adodb.recordset")
if request("AreaSearch")=1 then
'''''改寫下面這一句'''''
sql="select * from article where "& searchday &" (" & translate(keyword,"title") & ") order by id desc"
elseif request("AreaSearch")=2 then
sql="select * from article where "& searchday &" (" & translate(keyword,"content") & ") order by id desc"
''''''''''''
end if %>
改為''''''''
sql="select* from aticle where searchday=""and title="keyword" order by id desc"
elseif request("Areaserch")=2 then
sql="select* from article where searchday=""and content="keyword" order by
id desc"
對嗎
<form action="search.asp" method="post">
<tr >
<td colspan="2" align="center"> <input type=text size=12 name="keyword">
<br>
<select name="AreaSearch">
<option value=1>標題</option>
<option value=2>內容</option>
</select>
<br>
<select name="DateSearch">
<option value=all>所有時間</option>
<option value=1>昨天以來</option>
<option value=3>3 天以來</option>
<option value=7>7 天以來</option>
<option value=15>15天以來</option>
<option value=30>30天以來</option>
<option value=60>60天以來</option>
<option value=90>90天以來</option>
</select><br>
<input type=submit value="搜索" name="submit">
</td>
</tr>
</form>
select.asp頁面
<%
keyword=trim(request("keyword"))
dim searchday
if request("DateSearch")="all" then
searchDay=""
else
searchDay=" DATEDIFF('d',addtime,Now()) < "&request("DateSearch")&" and "
end if
dim pagecount,page,Spage,Epage,recordcount,i
page = request.querystring("page")
if page = "" or IsNull(page) then page = 1
if not IsNumeric(page) then page = 1
page = Cint(page)
set rs = server.CreateObject ("Adodb.recordset")
if request("AreaSearch")=1 then
'''''改寫下面這一句'''''
sql="select * from article where "& searchday &" (" & translate(keyword,"title") & ") order by id desc"
elseif request("AreaSearch")=2 then
sql="select * from article where "& searchday &" (" & translate(keyword,"content") & ") order by id desc"
''''''''''''
end if %>
改為''''''''
sql="select* from aticle where searchday=""and title="keyword" order by id desc"
elseif request("Areaserch")=2 then
sql="select* from article where searchday=""and content="keyword" order by
id desc"
對嗎
...全文
相关推荐
Oracle查询优化改写技巧与案例
避免在SQL语句中硬编码值,使用?占位符代替。
解决SQL Server SQL语句性能问题(9)——SQL语句改写(2)
本文对解决SQL Server SQL语句性能问题(9)——SQL语句改写(update语句改写、利用分析函数及利用CTE语句),结合实例进行了较为深入详细的说明和讲解,并对注意事项、关键知识点和选项等进行了重点标注和详尽解析,以便于读者进行深入学习和理解。
解决SQL Server SQL语句性能问题(9)——SQL语句改写(3)
本文对解决SQL Server SQL语句性能问题(9)——SQL语句改写(消除union及消除or),结合实例进行了较为深入详细的说明和讲解,并对注意事项、关键知识点和选项等进行了重点标注和详尽解析,以便于读者进行深入学习和理解。
sql语句妙用,各种sql语句的详细用法与讲解
本篇内容主要涉及SQL语句的详细用法,特别是动态SQL的运用,这对于编写流畅的程序至关重要。1. 动态SQL语句: 动态SQL允许在执行时构建SQL命令,这在需要根据变量或用户输入构建查询时非常有用。
Oracle Sql语句转换成Mysql Sql语句
本项目提供了一个Java源码工具,能够帮助用户便捷地将Oracle SQL语句转换为MySQL SQL语句。Oracle SQL与MySQL SQL的主要差异在于以下几个方面:1.


