简体   繁体   English

消息 156,级别 15,State 1,第 5 行关键字“LEFT”附近的语法不正确。 消息 156,级别 15,State 1,第 6 行 'b' 附近的语法不正确

[英]Msg 156, Level 15, State 1, Line 5 Incorrect syntax near the keyword 'LEFT'. Msg 156, Level 15, State 1, Line 6 Incorrect syntax near 'b'

USE [pfebd]
SELECT *
FROM TBCSBONNV a
WHERE TBCSJRNE<=20210422 AND TBCSECHE >=20210422 AND TBCSDBSC<=20210422 
LEFT JOIN 
(SELECT DISTINCT CPGCTGS ,CPGCPT,CPTENUM FROM CPTAXNV )b
ON a.TBCSAGCC=b.CPGCTGS AND a.TBCSNUCC=b.CPTENUM;

JOIN is an operator in the FROM clause. JOINFROM子句中的运算符 The WHERE clause follows the FROM clause. WHERE子句跟在FROM子句之后。 So you seem to want:所以你似乎想要:

SELECT c.*, a.*
FROM TBCSBONNV c LEFT JOIN
     (SELECT DISTINCT CPGCTGS, CPGCP, CPTENUM
      FROM CPTAXNV a
     ) a
     ON c.TBCSAGCC = a.CPGCTGS AND c.TBCSNUCC = a.CPTENUM;
WHERE c.TBCSJRNE <= 20210422 AND
      c.TBCSECHE >= 20210422 AND
      c.TBCSDBSC <= 20210422 ;

I replaced the table aliases with aliases that seem related to the table names TB C SBONNV and CPT A XNV.我用与表名 TB C SBONNV 和 CPT A XNV 相关的别名替换了表别名。

暂无
暂无

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

相关问题 Msg 156,Level 15,State 1,Procedure inventory,Line 6 [Batch Start Line 2]关键字&#39;Where&#39;附近的语法不正确 - Msg 156, Level 15, State 1, Procedure inventory, Line 6 [Batch Start Line 2] Incorrect syntax near the keyword 'Where' 消息156,级别15,状态1,第50行关键字“ GROUP”附近的语法错误 - Msg 156, Level 15, State 1, Line 50 Incorrect syntax near the keyword 'GROUP' 消息156,级别15,状态1,过程ShowDirectorateList,第739行关键字&#39;END&#39;附近的语法不正确 - Msg 156, Level 15, State 1, Procedure ShowDirectorateList, Line 739 Incorrect syntax near the keyword 'END' 消息156,级别15,状态1,行2493关键字“ ON”附近的语法错误 - Msg 156, Level 15, State 1, Line 2493 Incorrect syntax near the keyword 'ON' 消息156,级别15,状态1,第16行关键字“ IF”附近的语法错误 - Msg 156, Level 15, State 1, Line 16 Incorrect syntax near the keyword 'IF' 消息156,级别15,状态1,第22行在关键字“具有”附近的语法错误 - Msg 156, Level 15, State 1, Line 22 Incorrect syntax near the keyword 'having' 消息156,级别15,状态1,过程CLR_TRIGGER_NAUDOJASI,第1行关键字“插入”附近的语法错误 - Msg 156, Level 15, State 1, Procedure CLR_TRIGGER_NAUDOJASI, Line 1 Incorrect syntax near the keyword 'insert' 消息 156,级别 15,状态 1,第 7 行关键字“BETWEEN”附近的语法不正确 - Msg 156, Level 15, State 1, Line 7 Incorrect syntax near the keyword 'BETWEEN' 消息 156,级别 15,状态 1,第 2 行 关键字“case”附近的语法不正确。 我的 SQL 有什么问题 - Msg 156, Level 15, State 1, Line 2 Incorrect syntax near the keyword 'case'. Whats wrong in my SQL SQL Server:错误消息156,级别15,状态1,第12行关键字“ AS”附近的语法不正确 - SQL Server: error Msg 156, Level 15, State 1, Line 12 Incorrect syntax near the keyword 'AS'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM