简体   繁体   English

在Access 2007中向查询添加表达式的正确语法(

[英]Correct syntax for adding an expression to a query in Access 2007 (

I came across this How Do I Sequentially Number Records in an Access Query in order to do what I was trying to do based on this stackoverflow question I posted (which I never got to do what I was after) but each time that I try to add the AS Counter to the query I get 我遇到了这个如何在访问查询中按顺序对记录进行编号 ,以便根据我发布的这个stackoverflow问题 (我从来没有做过的事情)来做我想做的事情,但是每次尝试将AS计数器添加到我得到的查询中

The expression you entered contains invalid syntax
You may have entered an operand without an operator

using the following sql: 使用以下sql:

SELECT Maintable.NumBR, Maintable.*, [Ehow] AS Expr1
FROM Maintable
WHERE (((Maintable.[NumBR])="" 
  Or (Maintable.[NumBR]) Like "3101" 
  Or (Maintable.[NumBR]) Like "3541" 
  Or (Maintable.[NumBR]) Like "4381" 
  Or (Maintable.[NumBR]) Like "AS3281" 
  Or (Maintable.[NumBR]) Like "4260" 
  Or (Maintable.[NumBR]) Like "4315" 
  Or (Maintable.[NumBR]) Like "4330" 
  Or (Maintable.[NumBR]) Like "4382" 
  Or (Maintable.[NumBR]) Like "9410" 
  Or (Maintable.[NumBR]) Like "9570" 
  Or (Maintable.[NumBR]) Like "AS3710" 
  Or (Maintable.[NumBR]) Like "AS4450" 
  Or (Maintable.[NumBR]) Like "K400" 
  Or (Maintable.[NumBR]) Like "3100" 
  Or (Maintable.[NumBR]) Like "3130" 
  Or (Maintable.[NumBR]) Like "3280" 
  Or (Maintable.[NumBR]) Like "3495" 
  Or (Maintable.[NumBR]) Like "3540" 
  Or (Maintable.[NumBR]) Like "3610" 
  Or (Maintable.[NumBR]) Like "3700" 
  Or (Maintable.[NumBR]) Like "4110" 
  Or (Maintable.[NumBR]) Like "4200")

AND (([Ehow])=DCount("[NumBR]","[Maintable]"," [NumBR] <= " & [NumBR])));

EDIT the question posed in the previous stackoverflow question answers this question. 编辑上一个stackoverflow问题中提出的问题即可回答该问题。

The AS Counter phrase is not needed in your query. 您的查询中不需要AS Counter短语。 In the linked example, that's added to the SELECT statement to alias the column; 在链接的示例中,将其添加到SELECT语句中以对该列进行别名; in your example you're working with the WHERE clause, so that AS phrase wouldn't do anything (and is actually invalid). 在您的示例中,您正在使用WHERE子句,因此AS短语不会执行任何操作(实际上是无效的)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM