为什么我在收到此代码时会收到错误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;
我试过不包括分号,括号和其他一些东西,但没有一个有效。
答案 0 :(得分: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;
而不是,
答案 1 :(得分: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
答案 2 :(得分:0)
首先,最好使用可读缩进格式化查询;
其次,我认为您遇到了问题,因为您的SQL脚本不正确(where子句需要与 AND 一起使用。)
即
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;