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

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了access转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%>

提示“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%>
参考技术A 改为
<%
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 ='"&city&"' and stop >= getdate() and shouye=1 and pic <>"" order by top desc,money desc,adid desc"

你的top字段是什么意思?

以上是关于access转sql:在关键字 'top' 附近有语法错误,请高手帮忙解决的主要内容,如果未能解决你的问题,请参考以下文章

sql从表中选出特定行,并要top几行,怎么写

SQL中如果进行模糊查询整个表

使用 Switch 语句和左连接 Access SQL 选择 Top 1

MS-Access SELECT TOP N 子查询 SQL

关键字 'if' 附近有语法错误。

sql的insert语句错误,求助