-1

为什么我收到一条错误消息,指出SQL command is not properly ended当我有此代码时:

SELECT MATERIALID, 
       MATERIALNAME, 
       MATERIALTYPEID, 
       CURECODEID, 
       COMBINATIONCODE, 
       MATERIALSTATUSID, 
       ACTIVATED, 
       DEACTIVATED 
FROM   MATERIAL_HEADER 
WHERE  MATERIALID = 112, 
       MATERIALNAME = 3, 
       MATERIALTYPEID = 2, 
       CURECODEID = 0, 
       COMBINATIONCODE = 3, 
       MATERIALSTATUSID = 3;

我试过不包括分号、括号和其他一些东西,但没有一个奏效。

4

3 回答 3

8

尝试

SELECT MATERIALID, MATERIALNAME, MATERIALTYPEID, CURECODEID, COMBINATIONCODE, MATERIALSTATUSID, ACTIVATED, DEACTIVATED 
FROM MATERIAL_HEADER 
WHERE MATERIALID = 112 AND MATERIALNAME = 3 AND MATERIALTYPEID = 2 AND CURECODEID = 0 AND COMBINATIONCODE = 3 AND MATERIALSTATUSID = 3;

AND 而不是 ,

于 2013-08-08T13:41:11.130 回答
0
SELECT MATERIALID, 
       MATERIALNAME, 
       MATERIALTYPEID, 
       CURECODEID, 
       COMBINATIONCODE, 
       MATERIALSTATUSID, 
       ACTIVATED, 
       DEACTIVATED 
FROM   MATERIAL_HEADER 
WHERE  MATERIALID = 112 AND
       MATERIALNAME = 3 AND
       MATERIALTYPEID = 2 AND
       CURECODEID = 0 AND
       COMBINATIONCODE = 3 AND
       MATERIALSTATUSID = 3
于 2013-08-08T13:41:33.803 回答
0

首先,最好用可读的缩进来格式化查询;

其次,我认为您遇到了问题,因为您的 SQL 脚本不正确( where 子句需要与AND一起使用。)

IE

SELECT MATERIALID, MATERIALNAME, MATERIALTYPEID, CURECODEID, COMBINATIONCODE,         
MATERIALSTATUSID, ACTIVATED, DEACTIVATED 
FROM MATERIAL_HEADER 
WHERE MATERIALID = 112 AND MATERIALNAME = 3 AND MATERIALTYPEID = 2 AND CURECODEID = 0 AND 
COMBINATIONCODE = 3 AND MATERIALSTATUSID = 3;
于 2013-08-08T13:46:03.960 回答