关键字 'order' 附近有语法错误,应为ID,QUOTED_ID,或','

标签: 数据库 基础 关键字
4人阅读 评论(0) 收藏 举报
分类:

今天查询数据库时

select sum(goods_number)

from order

group by goods_id

怎么查询都报:关键字 'order' 附近有语法错误,应为ID,QUOTED_ID,或','错

最后,在网上百度出来order是关键字在order上加中括号,问题解决了

select sum(goods_number)

from [order]

group by goods_id

问题虽然解决了,但是以后使用会很不方便,所以最后将order表改了一下名字变成了orders,

为免以后再犯这样的问题这里将数据库一些常用的关键字列了出来以便以后创建数据表时注意:

A
ABSOLUTE            ACTION              ADD                 ADMINDB
ALL                 ALLOCATE            ALPHANUMERIC        ALTER
AND                 ANY                 ARE                 AS
ASC                 ASSERTION           AT                  AUTHORIZATION
AUTOINCREMENT       AVG

B
BAND                BEGIN               BETWEEN             BINARY
BIT                 BIT_LENGTH          BNOT                BOR
BOTH                BXOR                BY                  BYTE
                
C
CASCADE             CASCADED            CASE                CAST
CATALOG             CHAR                CHARACTER           CHAR_LENGTH
CHARACTER_LENGTH    CHECK               CLOSE               COALESCE
COLLATE             COLLATION           COLUMN              COMMIT
COMP                COMPRESSION         CONNECT             CONNECTION
CONSTRAINT          CONSTRAINTS         CONTAINER           CONTINUE
CONVERT             CORRESPONDING       COUNT               COUNTER
CREATE              CREATEDB            CROSS               CURRENCY
CURRENT             CURRENT_DATE        CURRENT_TIME        CURRENT_TIMESTAMP
CURRENT_USER        CURSOR
                
D
DATABASE            DATE                DATETIME            DAY
DEALLOCATE          DEC                 DECIMAL             DECLARE
DEFAULT             DEFERRABLE          DEFERRED            DELETE
DESC                DESCRIBE            DESCRIPTOR          DIAGNOSTICS
DISALLOW            DISCONNECT          DISTINCT            DOMAIN
DOUBLE              DROP
                
E
ELSE                END                 END-EXEC            ESCAPE
EXCEPT              EXCEPTION           EXCLUSIVECONNECT    EXEC
EXECUTE             EXISTS              EXTERNAL            EXTRACT
                
F
FALSE               FETCH               FIRST               FLOAT
FLOAT4              FLOAT8              FOR                 FOREIGN
FOUND               FROM                FULL
                
G
GENERAL             GET                 GLOBAL              GO
GOTO                GRANT               GROUP               GUID
                
H
HAVING              HOUR
                
I
IDENTITY            IEEEDOUBLE          IEEESINGLE          IGNORE
IMAGE               IMMEDIATE           IN                  INDEX
INDICATOR           INHERITABLE         INITIALLY           INNER
INPUT               INSENSITIVE         INSERT              INT
INTEGER             INTEGER1            INTEGER2            INTEGER4
INTERSECT           INTERVAL            INTO                IS
ISOLATION
                
J
JOIN
                
K
KEY
                
L
LANGUAGE            LAST                LEADING             LEFT
LEVEL               LIKE                LOCAL               LOGICAL
LOGICAL1            LONG                LONGBINARY          LONGCHAR
LONGTEXT            LOWER
                
M
MATCH               MAX                 MEMO                MIN
MINUTE              MODULE              MONEY               MONTH
                
N
NAMES               NATIONAL            NATURAL             NCHAR
NEXT                NO                  NOT                 NOTE
NULL                NULLIF              NUMBER              NUMERIC
                
O
OBJECT              OCTET_LENGTH        OF                  OLEOBJECT
ON                  ONLY                OPEN                OPTION
OR                  ORDER               OUTER               OUTPUT
OVERLAPS            OWNERACCESS
                
P
PAD                 PARAMETERS          PARTIAL             PASSWORD
PERCENT             PIVOT               POSITION            PRECISION
PREPARE             PRESERVE            PRIMARY             PRIOR
PRIVILEGES          PROC                PROCEDURE           PUBLIC
                
Q

R
READ                REAL                REFERENCES          RELATIVE
RESTRICT            REVOKE              RIGHT               ROLLBACK
ROWS
                
S
SCHEMA              SCROLL              SECOND              SECTION
SELECT              SELECTSCHEMA        SELECTSECURITY      SESSION
SESSION_USER        SET                 SHORT               SINGLE
SIZE                SMALLINT            SOME                SPACE
SQL                 SQLCODE             SQLERROR            SQLSTATE
STRING              SUBSTRING           SUM                 SYSTEM_USER
                
T
TABLE               TABLEID             TEMPORARY           TEXT
THEN                TIME                TIMESTAMP           TIMEZONE_HOUR
TIMEZONE_MINUTE     TO                  TOP                 TRAILING
TRANSACTION         TRANSFORM           TRANSLATE           TRANSLATION
TRIM                TRUE
                
U
UNION               UNIQUE              UNIQUEIDENTIFIER    UNKNOWN
UPDATE              UPDATEIDENTITY      UPDATEOWNER         UPDATESECURITY
UPPER               USAGE               USER                USING
                
V
VALUE               VALUES              VARBINARY           VARCHAR
VARYING             VIEW
                
W
WHEN                WHENEVER            WHERE               WITH
WORK                WRITE
                
X

Y
YEAR                YESNO
                
Z
ZONE


查看评论

'(' 附近有语法错误

先粘贴一下代码     "             SelectCommand="SELECT [公告编号] AS AnnouceID, LEFT([公告名称],15) AS Title F...
  • qingyushan
  • qingyushan
  • 2013-11-28 23:01:10
  • 744

关键字“ ”附近有语法错误

解决1:加中括号 解决2:换名 下面这些词都是T-SQL语句中的关键字,在你写SQL语句,存储过程,触发器或字段命名等时要避免使用这些词。 ADD EX...
  • xyykt
  • xyykt
  • 2012-05-13 23:13:51
  • 4467

System.Data.SqlClient.SqlException 关键字 table 附近有语法错误。

ADO.net读SQLServer数据库时,数据库表的名字不能用一些关键字建立,如“User”,“Table”等。如果用这些字段,在用SqlDataAdapter类填充dataset的fill方法时,...
  • chen131
  • chen131
  • 2010-06-24 00:34:00
  • 1437

Hibernate--关键字 'user' 附近有语法错误

刚刚学hibernate,总是出现问题。现在给大家一些建议,免得浪费时间,在那里不停的调啊,调啊。关键字 'user' 附近有语法错误GetGeneratedKeysDelegate.executeA...
  • Koupoo
  • Koupoo
  • 2010-12-28 11:31:00
  • 1890

mybatis中出现“@P0' 附近有语法错误。

org.springframework.jdbc.BadSqlGrammarException: ### Error querying database. Cause: com.microsoft...
  • lohannes
  • lohannes
  • 2018-01-11 10:46:20
  • 86

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

最近我在开发中遇到个挺棘手的问题,一段T-SQL语句在开发环境中明明跑得好好的,发布到生产环境却报错。...
  • b6_g9
  • b6_g9
  • 2015-07-01 10:08:57
  • 2390

关键字'table'附近有语法错误

直接上问题: java.lang.RuntimeException: java.sql.SQLException: 关键字 ‘user’ 附近有语法错误。 Query: select * from...
  • lihaibo112924
  • lihaibo112924
  • 2016-10-21 16:46:56
  • 777

“在关键字 'COLUMN' 附近有语法错误。”是怎么回事?其实很简单!

在ASP程序中,想通过ASP在数据表中添加新字段,根据“sql中文参考手册.chm”中所述,用了“ALTER TABLE Employees ALTER COLUMN Salary CHAR(20)”...
  • worldwind13
  • worldwind13
  • 2004-11-19 12:32:00
  • 2539

sqlserver 2000_在关键字 'user' 附近有语法错误

在学校的时候写java程序,就遇到了这个问题,本来以为是数据库安装时候出错了,今天重新安装,仍然出现这个问题,百度了一下,才发现是一个很弱智的问题。服务器: 消息 156,级别 15,状态 1,行 1...
  • coharder
  • coharder
  • 2011-06-08 10:34:00
  • 1970

Java 链接 SQL Sever 关键字 'User' 附近有语法错误

今天做个后台登录,数据库表名为:"USER",做完后发现居然报表名USER符近有语法错误,又把SQL语句在SQL SERVER中运行,还是一样,找找资料原来USER是T-SQL语句中的关键字,所以要写...
  • qq_24531461
  • qq_24531461
  • 2017-03-04 13:36:09
  • 700
    个人资料
    持之以恒
    等级:
    访问量: 638
    积分: 374
    排名: 20万+
    文章分类
    文章存档
    最新评论