2012-09-13 46 views
1

我有一個複雜的SQL語句,當我加入這個'select'語句時出現錯誤。他們提示我這個錯誤: Error in Join expression. Can't parse query text.如何解決此錯誤:「聯接表達式中的錯誤。無法解析查詢文本」

我粘貼了這個SQL語句,我認爲會導致此錯誤。任何人都可以告訴我哪裏出了問題?我從來沒有把整個SQL語句粘貼到這裏,因爲我認爲如果你需要的話,這會很麻煩,請告訴我。有任何想法嗎???

SELECT  AllocationDate, LocationName, StationName, Hour1, Hour2, Hour3, Hour4, Hour5, Hour6, Hour7, Hour8, Hour9, Hour10, Hour11, Hour12, EmpName, ShiftTime, 
        BreakTime, SignIn, SignOut 
FROM   (SELECT  z.AllocationDate, z.LocationName, z.StationName, a.Hour1, b.Hour2, c.Hour3, d .Hour4, e.Hour5, f.Hour6, g.Hour7, h.Hour8, i.Hour9, j.Hour10, k.Hour11, 
               l.Hour12, m.EmpName, m.ShiftTime, m.BreakTime, m.SignIn, m.SignOut 
         FROM   (SELECT DISTINCT AllocationDate, LocationName, StationName 
               FROM   satsschema.viewmain 
               WHERE  (StationName IS NOT NULL)) z LEFT OUTER JOIN 
                (SELECT DISTINCT AllocationDate, LocationName, StationName, Hour1 
                 FROM   satsschema.view00000100) a ON z.LocationName = a.LocationName AND z.StationName = a.StationName AND 
               z.AllocationDate = a.AllocationDate LEFT OUTER JOIN 
                (SELECT DISTINCT AllocationDate, LocationName, StationName, Hour2 
                 FROM   satsschema.view01000200) b ON z.LocationName = b.LocationName AND z.StationName = b.StationName AND 
               z.AllocationDate = b.AllocationDate LEFT OUTER JOIN 
                (SELECT DISTINCT AllocationDate, LocationName, StationName, Hour3 
                 FROM   satsschema.view02000300) c ON z.LocationName = c.LocationName AND z.StationName = c.StationName AND 
               z.AllocationDate = c.AllocationDate LEFT OUTER JOIN 
                (SELECT DISTINCT AllocationDate, LocationName, StationName, Hour4 
                 FROM   satsschema.view03000400) d ON z.LocationName = d .LocationName AND z.StationName = d .StationName AND 
               z.AllocationDate = d .AllocationDate LEFT OUTER JOIN 
                (SELECT DISTINCT AllocationDate, LocationName, StationName, Hour5 
                 FROM   satsschema.view04000500) e ON z.LocationName = e.LocationName AND z.StationName = e.StationName AND 
               z.AllocationDate = e.AllocationDate LEFT OUTER JOIN 
                (SELECT DISTINCT AllocationDate, LocationName, StationName, Hour6 
                 FROM   satsschema.view05000600) f ON z.LocationName = f.LocationName AND z.StationName = f.StationName AND 
               z.AllocationDate = f.AllocationDate LEFT OUTER JOIN 
                (SELECT DISTINCT AllocationDate, LocationName, StationName, Hour7 
                 FROM   satsschema.view06000700) g ON z.LocationName = g.LocationName AND z.StationName = g.StationName AND 
               z.AllocationDate = g.AllocationDate LEFT OUTER JOIN 
                (SELECT DISTINCT AllocationDate, LocationName, StationName, Hour8 
                 FROM   satsschema.view07000800) h ON z.LocationName = h.LocationName AND z.StationName = h.StationName AND 
               z.AllocationDate = h.AllocationDate LEFT OUTER JOIN 
                (SELECT DISTINCT AllocationDate, LocationName, StationName, Hour9 
                 FROM   satsschema.view08000900) i ON z.LocationName = i.LocationName AND z.StationName = i.StationName AND 
               z.AllocationDate = i.AllocationDate LEFT OUTER JOIN 
                (SELECT DISTINCT AllocationDate, LocationName, StationName, Hour10 
                 FROM   satsschema.view09001000) j ON z.LocationName = j.LocationName AND z.StationName = j.StationName AND 
               z.AllocationDate = j.AllocationDate LEFT OUTER JOIN 
                (SELECT DISTINCT AllocationDate, LocationName, StationName, Hour11 
                 FROM   satsschema.view10001100) k ON z.LocationName = k.LocationName AND z.StationName = k.StationName AND 
               z.AllocationDate = k.AllocationDate LEFT OUTER JOIN 
                (SELECT DISTINCT AllocationDate, LocationName, StationName, Hour12 
                 FROM   satsschema.view11001200) l ON z.LocationName = l.LocationName AND z.StationName = l.StationName AND 
               z.AllocationDate = l.AllocationDate LEFT OUTER JOIN 
                (SELECT  a.EmpName, CONCAT(b.StartTime, ' - ', b.EndTime) AS ShiftTime, CONCAT(a.EmpTime, ' - ', ADDTIME(a.EmpTime, '0 1:0:0.000000')) 
                       AS BreakTime, a.Break, a.EmployeeOnBreak, '' AS SignIn, '' AS SignOut 
                 FROM   satsschema.employeeslot a JOIN 
                       satsschema.ufis b m ON b.UFISID = a.UFISEmpGroup) Morning 
         WHERE  (AllocationDate = @AllocationDate) AND (LocationName = @LocationName) AND (StationName <> '') AND (Break = 1) 
         GROUP BY StationName, LocationName, AllocationDate 
+0

這個片段中擁有無與倫比的括號,但我懷疑這是因爲它只是語句的一部分?查詢是否在MySQL中工作 - 刪除您正在使用的任何C#構造(ADO.NET?實體框架?)? –

回答

2

ON條款是括號) m ON b.UFISID = a.UFISEmpGroup外,試試這個,

SELECT a.EmpName, 
     CONCAT(b.StartTime, ' - ', b.EndTime) AS ShiftTime, 
     CONCAT(a.EmpTime, ' - ', ADDTIME(a.EmpTime, '0 1:0:0.000000')) AS BreakTime, 
     a.Break, 
     a.EmployeeOnBreak, 
     '' AS SignIn, 
     '' AS SignOut 
FROM satsschema.employeeslot a JOIN satsschema.ufis b m 
     ON b.UFISID = a.UFISEmpGroup 
+0

雖然它提示出相同的錯誤。錯誤是在其他SQL語句的某處?這只是其中的一部分。我應該粘貼整個sql語句而不是這部分? – Philemon

+0

好得多,如果你可以發佈整個部分。 –

+0

好的。我將在稍後編輯我的帖子。回來幾分鐘。 – Philemon