简体   繁体   English

消息156,级别15,状态1,行2493关键字“ ON”附近的语法错误

[英]Msg 156, Level 15, State 1, Line 2493 Incorrect syntax near the keyword 'ON'

I know that this question may be asked quite often but I have been trying to find the issue with this left join. 我知道这个问题可能经常被问到,但是我一直在尝试通过这种左联接找到问题。 I have searched around and tried a few different things but I am still having trouble identifying what is wrong with it. 我四处搜寻并尝试了一些不同的方法,但仍然无法确定问题所在。

left join (
    SELECT
        MAX(e.date) as MaxDate
        ,e.patientID
    FROM
        labdata ld
        inner join enc e on e.encounterID = ld.EncounterId
            and e.deleteFlag = 0
            and ld.deleteFlag = 0
            and ld.futureflag = 0
            and ld.cancelled = 0
            and ld.received = 1
        inner join @patients t on t.patientID = e.patientID
        inner join structsocialhistory SSH on SSH.encounterId = e.encounterID
        INNER JOIN (structdatadetail SDD ON SSH.catid = SDD.catid      
                AND     SSH.itemid = SDD.itemid 
                AND   SSH.detailid = SDD.id)
        WHERE SSH.catid  = 10619
        AND SSH.itemid = 318681 
        AND SSH.detailID = 49 AND SSH.ValueID =82
        OR SSH.detailID = 51 AND SSH.ValueID IN(88,89,145)
        AND SSH.detailID IN(52,53,98,99,100,101,106,107,108,109) AND CONVERT(VARCHAR(MAX), SSH.Value) = 'Yes'

    GROUP BY
        e.patientID
) SmokeCounselMaxDate on SmokeCounselMaxDate.patientid = u.uid

Remove the brackets from this bit: 从以下位置卸下支架:

INNER JOIN (structdatadetail SDD ON SSH.catid = SDD.catid      
            AND     SSH.itemid = SDD.itemid 
            AND   SSH.detailid = SDD.id)

Check this I removed the brackets at table structdatadetail 检查一下我删除了表structdatadetail的括号

left join ( SELECT MAX(e.date) as MaxDate ,e.patientID FROM labdata ld inner join enc e on e.encounterID = ld.EncounterId and e.deleteFlag = 0 and ld.deleteFlag = 0 and ld.futureflag = 0 and ld.cancelled = 0 and ld.received = 1 inner join @patients t on t.patientID = e.patientID inner join structsocialhistory SSH on SSH.encounterId = e.encounterID INNER JOIN structdatadetail SDD ON SSH.catid = SDD.catid 左联接(SELECT MAX(e.date)as MaxDate,e。Patient ID FROM labdata ld内部联接ene e on e.encounterID = ld.EncounterId和e.deleteFlag = 0和ld.deleteFlag = 0以及ld.futureflag = 0和ld.cancelled = 0和ld.received = 1内部连接@t病人t上t.patientID = e。PatientID内部连接structsocialhistory SSH on SSH.encounterId = e.encounterID INNER JOIN structdatadetail SDD ON SSH.catid = SDD.catid
AND SSH.itemid = SDD.itemid AND SSH.detailid = SDD.id WHERE SSH.catid = 10619 AND SSH.itemid = 318681 AND SSH.detailID = 49 AND SSH.ValueID =82 OR SSH.detailID = 51 AND SSH.ValueID IN(88,89,145) AND SSH.detailID IN(52,53,98,99,100,101,106,107,108,109) AND CONVERT(VARCHAR(MAX), SSH.Value) = 'Yes' AND SSH.itemid = SDD.itemid和SSH.detailid = SDD.id其中SSH.catid = 10619 AND SSH.itemid = 318681 AND SSH.detailID = 49 AND SSH.ValueID = 82或SSH.detailID = 51 AND SSH.ValueID IN(88,89,145)和SSH.detailID IN(52,53,98,99,100,101,106,107,108,109)和CONVERT(VARCHAR(MAX),SSH.Value)='是'

GROUP BY
    e.patientID

) SmokeCounselMaxDate on SmokeCounselMaxDate.patientid = u.uid )SmokeCounselMaxDate.patientid = u.uid上的SmokeCounselMaxDate

暂无
暂无

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

相关问题 消息 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' Msg 156,Level 15,State 1,Procedure inventory,Line 6 [Batch Start Line 2]关键字'Where'附近的语法不正确 - 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行关键字'END'附近的语法不正确 - Msg 156, Level 15, State 1, Procedure ShowDirectorateList, Line 739 Incorrect syntax near the keyword 'END' 消息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