access转sql:在关键字 'top' 附近有语法错误,请高手帮忙解决

来源:百度知道 编辑:UC知道 时间:2024/05/07 03:29:59
<%
if city="" then
sql="select top 3 * from nyeee_data where mark='yes' and mark='yes' and stop >= getdate() and shouye=1 and pic <>'' order by top desc,money desc,adid desc"
else
sql="select top 3 * from nyeee_data where mark='yes' and city ='"&city&"' and mark='yes' and stop >= getdate() and shouye=1 and pic <>'' order by top desc,money desc,adid desc"
end if
set rs=server.createobject("adodb.recordset")
rs.open sql,connstr,1,1
if rs.eof then%>

提示“top”附近有语法错误,请帮忙看看,谢谢

TOP是SQL保留字你改成:[top]

<%
if city="" then
sql="select top 3 * from nyeee_data where mark='yes' and mark='yes' and stop >= getdate() and shouye=1 and pic <>'' order by [top] desc,money desc,adid desc"
else
sql="select top 3 * from nyeee_data where mark='yes' and city ='"&city&"' and mark='yes' and stop >= getdate() and shouye=1 and pic <>'' order by [top] desc,money desc,adid desc"
end if
set rs=server.createobject("adodb.recordset")
rs.open sql,connstr,1,1
if rs.eof then%>

改为
<%
if city="" then
sql="select top 3 * from nyeee_data where mark='yes' and stop >= getdate() and shouye=1 and pic <>"" order by top desc,money desc,adid desc"
else
sql="select top 3 * from nyeee_data where mark='yes' and city ='